Hey. I want the player to be able to toggle if he should fly or be grounded. So when(for example) the player presses “f” then he can fly and when he presses it again he stops. How would I put that in a simple line of code ?
Which script are you currently using? I’ve modded the FPSWalker script of days gone by to turn gravity off, if that’s any clue. Look in your code where gravity is applied. Make a ‘flying’ var (boolean) that when it’s ‘true’ you don’t apply gravity. And have Update look for the ‘f’ key to toggle that ‘flying’ boolean.
var flying = false;
function Update()
{
if (Input.GetKeyDown("F"))
flying = !flying;
}
What i want is for the player to be able to togle it on or off.