I’m trying to print the Actor-Test’s transform in the GameMode, but why does it only show the correct values if a delay in GameMode is used?
Here’s my blueprints for GameMode and my Actor-Test (the Actor-Test is placed in the world at: x: 123, y: 123, z: 123):
This is likely that your Event Begin Play is too fast for it’s own good (game mode likely initializes before the objects in your scene have registered), I have had a couple of cases where I have to use minuscule delays like that as well because things simple happen too fast, I doubt there is any fix for this, but that is just my input.
Why not have the actor “Test” call an event on the game mode in place of Begin Play. That way Test (should) will always be ready before the game mode print string.
I tested a few things, it seems I have to use a delay in GameMode if I want Actors to set values in GameMode (if I’m using the same variable in Event BeginPlay).
Yes, the BeginPlay of the GameMode is called earlier than the Actor’s BeginPlay. With that Delay, the Actor gets a small timegap in which he is spawned and its BeginPlay can call.
You will not want to use delays like that. There can always be a lag or something, which is longer than your Delay, and the BeginPlay is, AGAIN, too late.
If you want to make sure that something is called at the time an Actor is available, you need to use its own BeginPlay.
If you want to GameMode to do something when the Actor is ready, you will want to create a CustomEvent in the GameMode and call it from the BeginPlay of the Actor.
Be sure that, in a Multiplayer Game, the GameMode is only available for the Server! Calling “GetGameMode” on the ClientSide, will result in a NULL reference.