- Home /
Different values of force applyed with AddForce don't change the speed of the gameobject
I'm learning how to use Unity3D and I'm on an animation problem. I have a GameObject, which is my character and I want him to jump. In a first place I used an input from the keyboard, the Space Bar.
jumpForce is public float variable and its values is 700
if (grounded && Input.GetKeyDown(KeyCode.Space)) {
anim.SetBool("Ground", false);
rigidbody2D.AddForce(new Vector2(0, jumpForce));
}
Then I tried to get the input from the XBox360 Controller Pad and everything's fine. But with the same code (just changed the GetKeyDown to GetButton for controller) the character jumps higher. With the controller, the max velocity reached is 53 (I get the value of rigidbody2D.velocity.y), but with the keyboard the value is at leat 13. If I change the value of jumpForce nothing happens, the values remain the same, but if I set it to 0 the character won't jump.
I would like to know which is the utility of the variable jumpForce and of the function AddForce, if it doesn't change the value of the speed. Thank you