Hi,
Many apologies if a similar thing has been asked before, a brief search didnt return anything particularly relevant.
I am currently struggling to identify within the ShooterGame project where respawns are handled for a player. I know that the GameMode creates the pawn initially using DefaultPawnClass, but on death the only thing that happens in the attached ‘online’ classes are an addition of a death/kill to the victim/killer and the broadcasting of a message detailing the death. The player controller is detached using DetachFromControllerPendingDestroy() from within the pawn and after some animations the dead pawn’s lifespan is set to 2 and it dies. I can’t seem to follow the trail to the piece of code (if its present and not in engine code) which a) keeps track of respawn timers and b) spawns the new actor.
I have seen calls to ServerRestartPlayer in an UnFreeze method in the controller but I cant see it called from anywhere.
Basically my question is, is there a standard ue4 respawn mechanism (lead to believe so by GameMode::bMinRespawnDelay (which I cant see used anywhere)), am I missing a vital piece?
Also:
I have also read that it is the responsibility of the controller to request a new pawn when dead but I cant see anything in ShooterPlayerController.cpp which handles a respawn timer or even calls the gamemode to create a new pawn
Ok, this may need deleted, or it may be useful to others…
I’ve found that calling APawn::DetachFromControllerPendingDestroy() makes a pawn set a controllers state to NAME_Inactive before dieing which calls a APlayerController::BeginInactiveState() which then registers a timer which calls APlayerController::UnFreeze() which is overriden by AShooterPlayerController.
Basically the pawn called DetachFromControllerPendingDestroy(), which set the controller inactive which triggered a respawn(UnFreeze()) delay(obtained from the game mode) which was overriden by AShooterPlayerController::UnFreeze() which called ServerRestartPlayer() which requests a a spawn from the gamemode.
This is now my understanding. It may need corrected. but for the time being Ill continue assuming its fairly correct.