Hello avere one ! Please help me with this qustion.
i have code for spawn PlayerCharacter. I need get Player reference for use in GameMode.
UWorld* const World = GetWorld(); //Ссылка на мир
if (World)
{
FActorSpawnParameters SpawnParams;
AEOnlineCharacter* Player = World->SpawnActor<AEOnlineCharacter>(CharacterBP);
GM->GetCharLocation();
//Получаем управление над заспавненым персанажем
Possess(Player);
}
which will place a pointer to your already possessed character into your GameMode class. MyGameModeClass is the class you created from AGameMode. Because of timing, be sure to test if MyCharacter exists/is not null prior to trying to use it in GameMode. You should then be able to use functions within your character class from GameMode.