// 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(Location, Rotation, SpawnInfo); GetPlayerController()->StartTurn(); } AMyPlayerController *AMyGameMode::GetPlayerController() { return dynamic_cast( UGameplayStatics::GetPlayerController(GetWorld(), 0) ); }