x


Character Respawn

Hello,

Currently in my game, I have the character respawning back to life in the exact same spot at the start of the game. But lets say the character makes it midway of the game and dies. How do I get the character to respawn midway of the game?

Here is the script Im currently using for character respawn.

private var StartPos : Vector3;
function Awake()
{
           StartPos = transform.position;
}
           function OnTriggerEnter(other : Collider)
{
            if(other.gameObject.name == "fallout")
{
            //RESPAWN!
            HealthGui.LIVES -= 1;
            StartPos.y += 4;

              transform.position = StartPos;
    }
}
more ▼

asked Jan 20 '11 at 09:04 PM

cortex gravatar image

cortex
41 31 31 34

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Why don't you setup a midway trigger object, and when the character hits the trigger you can change the value of your Vector3 that is the start position to the position of the trigger object. This way you are effectively just moving the spawn point to the middle of the level instead of the beginning.

more ▼

answered Jan 20 '11 at 09:11 PM

pfranza gravatar image

pfranza
96 1 1 8

agree with this one. Just make a checkpoint, with a script inside it that removes the activePt from the startingPoint.

May 12 '11 at 03:18 AM AnotherChris
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4394
x1491
x249

asked: Jan 20 '11 at 09:04 PM

Seen: 1994 times

Last Updated: Jan 20 '11 at 09:04 PM