I’m new in Unreal development. I have a question: I have created an object on my GameModeBase class. It is legal access this object from GameStateBase class? I don’t know if there is a good practices manual.
I’m developing Pong game with C++ only and I have created the ball in GameModeBase. I need to access it from GameStateBase to start move it when user press Spacebar.
But… I don’t know how to get access to GameModeBase
from GameStateBase
.
I get an instance of GameModeBase
this way:
UWorld* const world = GetWorld();
if (world)
{
ABall* ball = (Cast<AMyPongGameModeBase>(world->GetAuthGameMode()))->CurrentBall;
ball->StartMovement();
}
Maybe I’m think about how to do it instead of doing it.