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?
 

Justin

Administrator
Staff member
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.
 

Nikot93

New member
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
 

Justin

Administrator
Staff member
That'll spawn the object, but you'll still need to transfer ownership within PUN.
 

Vlaxep

Member
@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.
 

Vlaxep

Member
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