How to handle a multiplayer respawn in BP?

Maybe I’m doing it wrong, but I can’t seem to properly drive a respawn with default blank project.

Here is what I have:

  1. A custom game mode to handle server side spawning, a custom controller to issue spawning request, and a pawn that will find proper player start on server side. By using dedicated server and play in new window with 2 clients, everything works fine.

  2. I set the killZ to -200, and dive one client below, now my pawn dies, hit start or enter to issue a custom on server event. (So my Pawn is already killed by world settings. )

  3. now here is the problem. On my PlayerController when I try to get gamemode, it will return NULL(not valid), so it’s a server side thing, that’s cool. If I setup a switchHasAuthority, nothing happens(not even print) down the line, that’s weird but kinda make sense since PlayerController is not replicated.

  4. I now try use the event on my Pawn, use EventOnDestory, and make sure use switchHasAuthority to run following down the line. Now I can get GameMode and cast to my BP GameMode properly, I can call the custom event in my GameMode to spawn a new Pawn, no problem. But I can’t get a valid PlayerController. If during the execution line, I use GetController and cast to my PlayerController, the resulting PlayerController will not be valid.

  5. I checked the source, there is a ServerRestartPlayer() in APlayerController not expose to BP, and RestartPlayer() in AGameMode not exposed to BP as well. So far the only thing I can think of is to get proper player index on server side thus can bind server side controller to the pawn I spawned. BUT, from other question on answer hub, it seems to be not available to BP as well.

I wonder, if I missing any obvious way to handle multiplayer respawn from BP? Or is it going to be a long long wait in 4.2? Thanks first for any help.

I am interested in this to.

+++

Cheers

I think it’s doable Penguin, I’ve got multiplayer respawns to work in a few of my iterations. If I figure out a bulletproof system I’ll let you know. I have a feeling it has something to do with Gamestate and Playerstate.

here is my current progress.

I can possess the pawn on server side, but can not make the input working.(camera obviously snaps to new pawn replicated, but input lost function)

NOTE: in the post mentioned, I created a Pawn variable called myController to save reference to owning controller, which is NOT replicated. I assume that both server and client have their own pair and PlayerController server/client relationship will persist. Because during EventDestroyed, pawn to be destroyed will already be detached, if trying to use GetController will return NULL. I’m guessing I just hit a wall that needed to be solved on C++ side.

I got only the listen server working so far(make sense since the server side is working), but once I do dedicated server, non of the client will recover from respawn. Btw, now that you mentioned, there indeed have extra message I didn’t think they are important before.

After the controller failed to control new pawn, after a very long(like close to one minute.) time, log will start to compliant something like this.

LogNet:Warning: FRepLayout::SendProperties_r: Property has been unmapped longer than normal: Owner

LogNet:Warning: FRepLayout::ReplicateProperties: Properties have been unmapped longer than normal: PlayerState

LogNet:Warning: FRepLayout::SendProperties_r: Property has been unmapped longer than normal: Owner

LogNet:Warning: FRepLayout::ReplicateProperties: Properties have been unmapped longer than normal: PlayerState

It looks like a client complaint(LogNet), but didn’t state what is missing those 2 properties: Owner and PlayerState. Both clients complaints so that’s normal. But I can’t find anything to set Owner, and nothing related to PlayerState in BP(search from All classes in palette)

edit:formatting

After 2 nights digging through source code, I figured out how to do it properly and submitted a wiki page as my first major contribution. So here it is and hopefully it helps people that want to achieve this in the future.

I wanted to Say thank you your tutorial helped me understand where and how to work with the player controller. I thought it had to deal with the player index. I thought I would have to create an array of PC that have been created. This works amazing. I wanted to make it so it automatically re- spawned my player.
I know you can do use an on event destroyed, and I have used this method before I started making sure my pawn worked with networking and it worked. This didn’t work out well when I set everything right to work with network capabilities. Any ways you may know a better way to do this, but to find out if the pawn has been destroyed I use the get controlled pawn and test if it is valid on the PC event tick if it ever goes invalid it sets the respawn motions and poof Im back in and playing.

Thank you for your time, and your Wikki Page
You Rule!!!
I am almost ready to show off what I have been working on.
check up in the WIP on the Epic Forums if your interested in seeing what you have helped me create!!!

This helped me give a little of my sanity back

I can’t thank you enough penguin!!! Been struggling with this for quite a few days

Thank you PenguinTD, this tutorial helped me a lot.

they can’t get this more complicated can they?