A less floaty jump?

The code works, but the jump feels too “floaty”. Adjusting the gravity changes the height of the jump but the character still hangs in the air very unrealistically before coming down.

``````private var movementVector:Vector3 = new Vector3(0,0,0);
private var gravity:float = -10;
function Update(){
if(Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.W)){  //Check if player wants to jump
if(controller.isGrounded){  //Check if player can jump
Jump();
}
}

if(controller){
if(!controller.isGrounded){  //If the player is in the air
movementVector.y += gravity * Time.deltaTime;  //Apply some gravity, make him fall.
}
controller.Move(movementVector * Time.deltaTime);
}
}
function LateUpdate(){
transform.position.z = 0;
}
function OnGUI(){
GUI.Label(Rect(0, 0, 150, 50), "move: "+movementVector);
}

function Jump(){
movementVector.y = 10;   //Change the character's y velocity so he jumps.
}
``````

Is there a better way to do this?

make gravity greater?

I usually use this:

Physics.gravity.y * 2;

in all my character controller stuff. This links it to physics as well as gets a decent drop rate.

Physics.gravity.y is -9.8 or something close to that.

How tall is your character in units? Gravity accelerates objects towards the earth at 9.8 meters per second (per second). So as your gravity is close to that, your character should be around two units tall for the forces to match the “real world scale.” However I’ve always felt that real numbers leads to kind of slow-looking physics. I’m not sure why, it might be the level of detail in the real world usually gives you a lot more motion and stuff going on than in a computer game.

Usually I just increase the jump speed and the gravity together until I have something that matches what I want in the game. Increase both values = faster jump. Decrease both = slower jump. (If you go for a really fast jump, you might want to put some clamping on the max fallspeed)

Prob. you are using the wrong proportions…
Unity emulates the real world gravity. A elephant do not move fast as us, and we cant walk in water like some kind of bugs…

When working with unity try to use the more realistic proportions as possible… Make your character 1.8meters tall, and with 60Kg heavy.
Stuff like that helps the physics to be more realistic and avoid you to manually chance the gravity value.

Also check how the Unity demo character controller uses gravity and how to change it. For the default demo you can change the values in the inspector which is very helpful for testing.

Decrease the drag on your rigidbody.

1 Like

how?

Well, if you are just relying on Unity Physics:
https://docs.unity3d.com/Manual/class-PhysicsManager.html

1 Like