Hello community, when the player crash or moves to another map, it exits the game and then executes the OnLogout controller event.
The thing here is. How do I get to their location just before exiting?
In my case, I need them to drop all their items before exiting as they could have unique items that are needed to continue the game.
I tried to get the actor location of the controller and it didn’t work ( it’s not the real position ), also set on a tick the last position of the character in the controller, but it remains 0 for some reason I am still researching.
Anyone that could throw a bit of light on this is really appreciated.
What commands are you using to obtain the controller?
Are you calling the location check on the server?
How are you indexing the controllers on the server side binding it to the client identity?
Not a command, just the output variable of the onLogOut event
Yes the location check is being made in the server, the check is through the “get actor location” and the last position ( it’s cause I get 0, it’s not replicated to the server )
About the third question, could you please clarify it for me? Thanks
I guess the question remains is the actor destroyed before the logout event is called?
Maybe do an is valid test on the actor after logout.
Perhaps you could cast to custom controller that would hold this information in case of client disconnect. This would decouple the actor location from it in case of a crash.
Maybe you could do an override of the actors destroy function (OFC call super on the destruction) and pass on the information to the controller before the actor is destroyed. That way you would not have to constantly update it.
I would do a test myself but it’s pretty late on my end, so I can do a test in the morning at the earliest.
Edit: I was able to get the location with a manual logout
Edit2:
In your player controller you can override Event On Unpossess. It passes the unpossessed pawn from which you can get the location. It even works when doing a window close in a game session.
Hello, thanks for your quick response. I tested your suggestion, the unPossess event.
And it works fine, I get the location as it’s expected to what is quite nice, it’s the solution I was looking for, thanks for that.
But in my game mode in the onLogOut even when I ask for this variable it remains in the default value, even though I changed it in the unPossess, I think it’s a problem related my case and not a general problem.
Thank you very much for your help. Really appreciate it.
Be sure you are setting the variable inside of your custom player controller (that is where you override the unpossess function). Remember that the pawn after this phase no longer exists, so grab what you need and save it in your own variables for later use.