- Home /
Time limited actions
Hi, trying to make a power-up that allows the character to float for a limited amount of time. Got the float figured out and how to control the gravity from the 3rd Person Platformer tutorial. What I need now is to figure out how to make it so they player can only float for a limited amount of time, say 1 second before gravity takes effect as normal again.
Answer by tool55 · Feb 09, 2011 at 12:17 AM
Something like this should work. You haven't said how you're activating the power up (a button press, some sort of trigger object etc) so I haven't included a method for calling the GravityChange function. I'll leave that to you.
var useGrav : boolean = true;
function Update ()
{
rigidbody.useGravity = useGrav;
GravityChange ();
}
function GravityChange()
{
useGrav = false;
yield WaitForSeconds (1);
useGrav = true;
}
Your answer
Follow this Question
Related Questions
Reverse Gravity for a period of time 1 Answer
Starting/Triggering events based on hover time 0 Answers
Why can't I call function from another script? 1 Answer
CountDown Timer for Explosion 0 Answers
No esc when game over. 1 Answer