system
1
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.
tool55
2
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;
}