[BP] PlayerState gets spawned when Player leaves
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.
asked May 09 '15 at 11:40 PM in Bug Reports
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.
answered May 12 '15 at 10:28 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here