- Home /
Gravity Modifier Based On Hotkey
Hey guys, I've tried a bunch of codes but I don't seem to fully understand what I'm doing. I'm trying to make it so when I right click on my mouse, the gravity of my First Person Controller will be toggled from 55 and 15.
Can you guys give me an example code of some sort. At this stage, I'm only testing things out to get more knowledge with Unity so I won't be using anything you give me without your full permission, thanks.
I would prefer if this script/code was made to work as an individual script and not just a function of CharacterMotor or MouseLook.
How does your 'gravity' work? is it a rigidbody, or a CharacterController?
Answer by syclamoth · Nov 18, 2011 at 07:57 AM
In its most basic form, what you are looking for is-
if(Input.GetMouseButton(1))
{
gravity = 15;
} else {
gravity = 55;
}
But without any other information about exactly how your script works, I can't be any more detailed than that.