You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
974 B
34 lines
974 B
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#include "MyGameMode.h"
|
|
#include "Kismet/GameplayStatics.h"
|
|
#include "Trooper.h"
|
|
|
|
AMyGameMode::AMyGameMode() : Super() {
|
|
UE_LOG(LogTemp, Warning, TEXT("GameMode Constructor"));
|
|
PlayerControllerClass = AMyPlayerController::StaticClass();
|
|
}
|
|
|
|
void AMyGameMode::BeginPlay() {
|
|
Super::BeginPlay();
|
|
UE_LOG(LogTemp, Warning, TEXT("GameMode BeginPlay"));
|
|
if (GetWorld()->GetMapName().Contains("BattleFieldMap")) {
|
|
UE_LOG(LogTemp, Warning, TEXT("Player Logined"));
|
|
StartGame();
|
|
}
|
|
}
|
|
|
|
void AMyGameMode::StartGame() {
|
|
FVector Location(0.0f, 0.0f, 0.0f);
|
|
FRotator Rotation(0.0f, 0.0f, 0.0f);
|
|
FActorSpawnParameters SpawnInfo;
|
|
GetWorld()->SpawnActor<ATrooper>(Location, Rotation, SpawnInfo);
|
|
GetPlayerController()->StartTurn();
|
|
}
|
|
|
|
AMyPlayerController *AMyGameMode::GetPlayerController() {
|
|
return dynamic_cast<AMyPlayerController *>(
|
|
UGameplayStatics::GetPlayerController(GetWorld(), 0)
|
|
);
|
|
}
|