From AActor you can use GetWorld() and then GetWorld()->GetAuthGameMode().
UGameplayStatics::GetGameMode(this); should also work from inside aactor.
Keep in mind the game mode only exists on the server if you are working on a MP game. If this is your subclassed gamemode you will need to cast it as usual. I recommend saving this variable in a header variable instead of recasting every tick.
MyGameMode* GameModeRef = Cast<MyGameMode>(GetWorld()->GetAuthGameMode());
I have a custom AActor, and I want to call a method on my AGameMode. How should I go about that?
A small follow-up: is it alright to have actors talk to the game mode, or should things go the other way around? Also, considering MP, how does the GameMode and the Actors communicate? GameState?
You can have (serverside) actors talk to the game mode, it’s really down to the specific situation and is often better. For example if you need to “get all actors of class” from the game mode, it’s probably better to just have each actor call an event on the game mode to report something instead since getting all actors is expensive.
In MP there are two routes i like to use, for information that everyone needs to know the gamestate can replicate it once so all the clients can grab it from there (the gamestate exists on server and all clients). For information/events only one actor needs to know about, you can have the game mode call something on the serverside version of that actor, and then the actor can send it down.
You could also create another actor specifically for communication like that. I created a “gametype” replicated class for the extra flexibility over the gamestate of having some traditionally “game mode” logic in a separate replicated class i can destroy or re-create as needed during play.