- Home /
Spawn in last location
I have a spawn system that creates a prefab when the object (player) is destroyed. Its integrated with the dead sound. The problem is that it spawn the prefab at the place where the player respawns when is alive again. I need that the prefab appear at the LAST location, where the player was killed. Is there any posibility?
static var Player: Transform;
var prefab : Transform;
var spawn : Transform;
function Update () {
if(NetworkHealth.dead == true){
audio.Play();
for (var i : int = 0;i < 10; i++) {
Instantiate (prefab, Vector3(i * 2.0, 0, 0), Quaternion.identity);
}
}
}
Comment
Best Answer
Answer by highpockets · Feb 08, 2014 at 06:28 AM
Well, you have to get the players location when he dies: deathPos = transform.position;
And then pass that pos to the: Instantiate( prefab, deathPos, Quaternion.identity );