Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[BP] PlayerState gets spawned when Player leaves

Hey there,

i hope that this is NOT a bug, but i have no idea where it comes from.

I have my Lobby setup where a Player Hosts a Game as a listen Server and Clients can connect. This is all running well. My PlayerState tells the GameState on joining (BeginPlay), that he wants to be added to one of the Team Arrays. Also working.

This is the only place where i call the function to add the Player to a team!

Now, when i leave the lobby by either closing the game, going back to the main menu or kicking the player, the Player tells the Server to get rid of him (deleting him from the arrays). Also working.

BUT THEN a new PlayerState gets spawned ON SERVER SIDE although the player left.

How do i know this? Because the function gets called although no new PlayerState should be created. The one of the leaving player got destroyed (variables were reseted and the player vanished from the list).

But then from no where, the server spawns a fresh PlayerState, and the PState adds himself to the array (BeginPlay like i said) and i have a ghost Player.

Is this normal? When i rejoin and look into the scene outliner, i have more and more PlayerStates. The PlayerArray of the GameState shows the correct amount of PlayerStates, but in the debuggin area of the Blueprint etc, i can clearly see another PlayerState. And this happens for every extra client that connects and leaves.

Weird thing is. If i reconnect, the PlayerState does not remain in the lobby. I only got the clients one then.

:( I have no idea if i can recreate this in a fresh project an it is already 01:39 in germany. I will get some sleep and try this tomorrow. Otherwise i would love to send one of the Staff people my project in private to have a look at it.

Product Version: Not Selected
more ▼

asked May 09 '15 at 11:40 PM in Bug Reports

avatar image

6.8k 333 185 470

avatar image eXi May 09 '15 at 11:48 PM

It is version 4.7.5 BP only and downloaded from the Launcher.

I will take the work around to check if the Owner of the PlayerState is NULL when BeginPlay tries to add the PState to the Arrays. Seems to work, because this weird extra PlayerState doesn't event have an Owner...

PS: It gets spawned with a lifetime of 300sec when i click on it in the Outliner. Maybe that helps you to find the "issue".

avatar image Ben Halliday STAFF May 11 '15 at 10:26 PM

Hi eXi,

I'm looking into this now, but if you're able to send me a project to look at, that may speed things up for me. You can send me a download link via the forums, if you'd like:


Either way, I'll let you know what I find. Thanks for the report!

avatar image eXi May 12 '15 at 09:40 AM

Hey Ben, thanks for the time. I was already sleeping (past 0:00 in germany) and i guess now you are sleeping.

I will try to recreate this in a new project. If i am not able to, i will send you my project and a hopefully short instruction on what you need to do to see the PlayerState thingy.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Ok yeah, this is easily reproducalbe in a fresh Project an it seems like this is meant to be.

I will upload the fresh project i made here: https://drive.google.com/open?id=0B34nzTE-VVazRlZTaW9oSU5LaW8&authuser=0

Instructions: When you open the Project, you should be in the MainMenu Map. If not, look into the Maps folder.

In the Blueprint folder, you will find a LobbyBlueprint and a MainMenuBlueprint Folder. Inside of the MainMenu folder, there is a GameMode and a PlayerController (so we can start the game etc). Inside the Lobby folder, there is a GameMode, PlayerController und PlayerState.

Now start the game with 2 Players, but NO dedicated server. Make sure to start the game in the Editor window (this appears in standalone too i guess) so you can see the Outliner.

Then start the server on the Editor Window (the one INSIDE the Editor is the server by default) by pressing "C". I added Logs so you can see what happens. Then, go to the Window with the Client game and press "F" to find sessions. What a few seconds till the Log appears and says that the search was ok. Then press "J" to join the found session.

When creating the game, the Outliner should show ONE PlayerState. When joining the Game as the client, the Outliner should have TWO PlayerStates. All ok by now.

In the CLIENT window, press "E" to leave the Game and destroy the session. Now the PlayerState gets deleted BUT, the Server creates a new second one, which has a lifetime of 300 sec.

I added a Log Print for the PlayerState, so that you can see which PlayerState is calling the BeginPlay.

Also the PlayerState that gets created after the Client leaves, will remain on the Server even if the Player Reconnects.This is where my Game gets a problem. I need the PlayerState to fire BeginPlay when the Client connects and not after he left. The created PlayerState (watch the Number of the new one when the player disconnects) will NOT fire BeginPlay again. Only when the Player leaves. And since i use the Begin Play to add players to a list, this is really bad for me ):

Just try to disconnect (E), and reconnect a few times with the client. You will see that the PlayerState remains for him to reconnect.

I guess this is just something unreal intern, that the server leaves a PlayerStates for the point when the Player might reconnect. Is it possible to stop this from happening? A bool or something that i can set so that the Server doesn't do this? Or do i need to kill him by hand? The PlayerState has no owner, so i could call "destroy" in the begin play if he has no owner, but i don't like work arounds.

I also noticed that at least the client calls the BeginPlay again, maybe i will do a Client to Server call.

more ▼

answered May 12 '15 at 10:28 AM

avatar image

6.8k 333 185 470

avatar image eXi May 15 '15 at 04:42 PM

Hey Ben, we nearly hit 4 days, so i'm gonna bump this question by asking if you had time to look at it (: Got my "work around" (which is actualy only using the client side of the PlayerState) doing this by now, but i would be interested in more information about this.

avatar image Ben Halliday STAFF May 19 '15 at 03:00 PM

Hey eXi,

Sorry for the delay, I was out yesterday.

So I spoke with the network team, and they said this is intentional. As you noted, if the same Client reconnects with the Server, the PlayerState copy that was created when the Client left is reacquired by the Client.

There doesn't seem to be an .ini setting for this, but you can certainly disable it in code if you'd like.

In the GameMode class:

  • InactivePlayerStateLifeSpan - config time value

  • AddInactivePlayer() (and yes it does duplicate there, so there is your copy) FindInactivePlayer()

In the GameState class:

  • InactivePlayerArray

All initiated from:

  • APlayerController::CleanupPlayerState()

Hope that helps!

avatar image eXi May 20 '15 at 12:15 AM

Awesome Ben!

I will save this information. Would it be possible for you to speak to the doc team so that they add this information? I think this is pretty important to know!

And yes it helps a lot, thank you sir.

avatar image Ben Halliday STAFF May 20 '15 at 03:42 PM

I definitely will =)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question