Assign Players

Hi everyone. For my co-op game,I have made a grave system. For example,if there’s 4 players that are playing,there’ll be 4 graves. I want each grave to belong to a player,and if they die I want them to respawn from there. How can I assign the players to the graves?

output

Hi Blacies,

There a couple ways to do this depending on your setup. If you’re just getting started, a simple way to do it would be to:

  1. In your character class, make a variable for your grave, name it Grave. Under Details, set it to be Instance Editable
  2. In your scene, remove the Player Starts, and instead drag in four copies of your character. Set their Auto Posses Player to be Player 0, Player 1, Player 2, and Player 3 respectively.
  3. When you select your character, there will now be a Grave variable in the details window. Set each character to the grave you want them to use.
  4. When you want a character to die and respawn, you can simply set the position of the character to be the grave’s location with the SetActorLocation node.

In the example I added a little polish like a death and respawn animation, but those are just bells and whistles on top of this strategy.

The answer changes a bit depending on if you’d like to use the default Unreal player start system, or players are getting different types of pawns to posses, etc. Does this help?

2 Likes

Thanks a lot!