How to spawn different character on die (respawn)?

Nikot93

New member
hi,

when my player is dead, i want to spawn a different character prefab. How i can do that?
Any suggestions please?
 
With PUN it's going to be more difficult so I would first get it working with a single player game. You can do that by subscribing to the OnRespawn event and spawning a new prefab. With PUN you'll need to do that an then also transfer ownership to the new character from your local client.
 
With PUN it's going to be more difficult so I would first get it working with a single player game. You can do that by subscribing to the OnRespawn event and spawning a new prefab. With PUN you'll need to do that an then also transfer ownership to the new character from your local client.

If instead of using the subscription to the respawn event, I set a gameobject that must be instantiated after death, could it be a good solution?

Like this:
Spawn on death.PNG
 
That'll spawn the object, but you'll still need to transfer ownership within PUN.
 
@Nikot93 have you achieved this yet?

Thinking this could work for my game too.... I need players to be able to choose different 'classes' to spawn as.
 
That'll spawn the object, but you'll still need to transfer ownership within PUN.
Hi @Justin

Is this a good way to change Player character to another Prefab on the spot? (Character change requiring new prefab)

I'm thinking at the instant Player initiates character change:
- Set 'Spawned Objects on Death' to desired prefab
- damage player by 100%
- Object spawns, transfer ownership

Will this allow the 'Player' and the 'Character' in terms of SpawnManagerBase to all be in sync? ie. the m_Players, m_Playercount all variables relating to this Character and this Player owning it, PhotonView values etc., and in my case this would be their new actual playing character not just a 'ghost'??
 
Top