i have a project where a player can host a server and others can connect, the gamemode haves delayed start and it starts players as spectators, this means at the beginning all players spawn as spectators and then the host can call START MATCH on the gamemode.
after this all players spawn with their default pawns and new connections still spawn as spectators.
i want to add the option to let spectators spawn when the server desires to, for example when any player reaches a checkpoint it will spawn all the spectators as players.
to sum up my question are:
1 - How do i unpossess the pawn and posses the spectator when a player dies?
I know the Destroy Actor node destroys the pawn and unpossess it, but is that all? do i have to make a Run On Client event and just destroy self?
and after that should i create an actor pawn and possess it?
2 - how do i respawn all dead players and spectators on a custom event called by the server? should it be a Run On Client and then the same process as before?
to respawn i tried using a Run On Server event with the player controller as parameter, inside it i destroyed the actor, spawned a new one and possessed it, but it is not working.
after this the client can’t move, the player is spawned but only locally and i can’t control it
i think i got the respawning working
so i got my die/respawn system working just fine but it is a little mess, for the server to kill or respawn someone i have to take the PlayerController as a paramenter and i couldn’t find a way to get the player controller inside the server
i did this:
inside the server i call this function from the character and it gets executed on the client, it simply takes a reference to its playercontroller and then executes a function on the server inside the playercontroller
inside this function i:
check if this player is alive, it it is i destroy his actor and then let him possess the spectator actor, then set a boolean variable that i also use to notify the player and do changes in the UI( i have 2 widgets, 1 for spectators and 1 for alive players)
is there a better way of doing this?