is locally controlled always false after respawn. Multiplayer

Hello,

When I try to respawn the player in the game after he is being killed the UI doesnt show because the “Is Locally controlled” always returns false.
I cant seem to fix the issue I have a described my blueprint code below if you see the problem please let me know.

So this code handles the damage the player receives DamageAll runs on the server, owndeath runs on owning client and multicast death runs multicast. I get the player first person game mode and the player controller and run choose spawn point.

This is the code that runs in the firstpersongamemode. choose spawnpoint is a run on server event. it will pick a random spawnpoint and spawn the player then the player gets possesed by the player that died so he can controll him.

This is the code that adds the ui to the screen. AddlocalWidget is a run on owning client event that gets called in the beginplay of a child component(the gun) of the playercharacter.

I cant seem to find out why this is happening if you know what is wrong or how to do this the “right” way please let me know.

if you need some more info just ask.

thank you

Is Locally Controlled = Controller && Controller->IsLocalController()
Maybe you need to re-initialize/attach the controller to the character,
Either way you can use print string (debug) to check if your controller is null
Also u can set bIsLocalPlayerController (Part of Player Controller Class) to true if the problem is with the second part of the code (Controller->IsLocalController())

Replication takes time. GM spawns and then replicates Pawn. Possession happens then gets replicated.

Begin Play executes immediately when the actor is ready on the client. It may not yet be possessed.

The gun Actor may not be attached to the character at the time of Begin plays execution.

Add a delay of 0.2 to the begin play. This is a dirty work around. If it fixes the issue look at implementing Events or Polling.

2 Likes

Thank you for the solution. I hate that it works but it works. Thanks

1 Like

I suggest you set up polling or triggered events. A delay time of 0.2 might be good for some systems, but may need more time on others. Solution has to work for everyone consistently.

1 Like

Yeah I will try that thank you. One quick question, do you a good way to resolve the high ping/rubberbanding the clients get when playing? Thank you

Closer server locations. That’s all you can do.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.