x


Wait for seconds?

Hi there i am wandering if someone could please let me know how to insert the yeild.WaitForSeconds(5); into this script it has to be after the HealthControl.LIVES-=1; so that i have enough time to play an animation

private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "fallout") { dead = true;

        HealthControl.LIVES -=1;

        }

}

function LateUpdate() { if(dead)

{

    transform.position = Vector3(69.05988,0.8250099,0.01707077);

    dead = false;
}

}

more ▼

asked May 11 '11 at 02:07 PM

john 9 gravatar image

john 9
9 9 10 14

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

1 answer: sort voted first

Try this:

function OnControllerColliderHit(hit : ControllerColliderHit) { 
   if(hit.gameObject.tag == "fallout") {
      HealthControl.LIVES -=1;
      yield WaitForSeconds(5);
      dead = true;

   }
}
more ▼

answered May 11 '11 at 02:12 PM

oliver-jones gravatar image

oliver-jones
3.6k 240 285 335

Works but now it is taking away all my lives

May 11 '11 at 08:18 PM john 9

This does not work for me. What is yield?

Feb 16 '13 at 12:43 AM JonathanO

What is yield? I wonder how I could find that out.

Feb 16 '13 at 02:50 AM dubbreak
(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:

x239

asked: May 11 '11 at 02:07 PM

Seen: 10208 times

Last Updated: Feb 16 '13 at 02:50 AM