Download

(Question) Respawning a player via it's transform only works if delay is used, why?

Hi, I’ve encountered something today and I would just want to know why.

I’m using the “Respawning a Player in Blueprints” from the Docs](https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/RespawnPlayer/Blueprints/index.html).

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):

GameMode
8c6f32d13c960be26d894dda988f9f65f78d438b.png

Actor-Test
55a50860af2a119b4e59686ccb163956d0f55e3f.png

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.

That’s what I thought, you are probably right.

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.

I second this, don’t use delays to work around bugs like this. But judging from DevSaucy’s tone he wasn’t planning to. :slight_smile:

Correct. I’d rather not use delays.

I found (as eXi said) CustomEvent in GameMode and call it from the BeginPlay of the Actor works how I want it to. :slight_smile:

I’m just doing a singleplayer game for now, multiplayer is far into the future haha.

Thanks for the help everyone!