- Home /
rigibody's jumpping
I am coding the jump function on my 3d game,
while I cannot make it as I expected.
I expected my character can jump as how Mario jump,
(neglected the small or big jump)
While my character jump with a very quick speed,
and even it will fall on to the ground.
I have set the Edit->project setting->physics's gravity to y=-500
with the character rigibody's mass=5,
drag=0 and
angular drag=0.05
A video describe my problem
https://www.youtube.com/watch?v=-NKpMFsjNMk&feature=youtu.be
With my code
void FixedUpdate () {
myPlayer.updateCharacterMovement ();
checkJump ();
}
void checkJump(){
if(Input.GetKey(KeyCode.Space)&&isGrounded){
jumpCharacter();
}
}
void jumpCharacter(){
myPlayer.rb.AddForce (new Vector3(0, 500, 0), ForceMode.Impulse);
isGrounded = false;
}
void OnCollisionEnter(Collision collision){
Debug.Log (collision.gameObject.name);
if(collision.gameObject.layer==LayerMask.NameToLayer("Terrain")){
Debug.Log ("Ground");
isGrounded=true;
}
}
If your models are around 1 unit/meter then the gravity should around the same as earths, -10. -500 units/second^2 (50x earths gravity) seems way too high.
how could i know how many unit oer meter for my model? I have tried to set gravity as -9.81, but my model fall very slow
Then your models are way to big, scale them down.
Edit: One unit in Unity can be taken as 1 real meter.