Download

[Networking] Player Leave Game event

I’ve been searching through the docs and source, but can’t seem to locate an event or function to override that is called when the player leaves the game? I keep references to various player data inside the gamemode, but can’t tell when the player leaves or drops.

Also, what determines which objects are destroyed/removed when a player leaves the game? Currently when a player leaves the game, despite its controller being the owner of several actors, they aren’t destroyed. I can manually destroy them once I know of the event that is called when the player leaves; I’m just wondering if this is the expected behaviour.

Player is represented by APlayerController which child is always created by default when you create new C++ project, object of this class is created for each player connected to multiplayer, if you making single player you got one playercontroller object. When player leaves the game session his controller object is gonna be destroyed, so you could place your leave code atleast in OnDestroyed() but you might find better function to override. I coding single player game so i was not interested in it, but defiantly you should do that in in your APlayerController child.