My Character is Jumping at different heights with physics for no reason

My Character is jumping at different heights and I just cant figure out why?

My Character jumps at a shorter height when he is standing right beside a cube. Why is this happing, i do not have friction on it, it shouldn’t work this way.

The character have the following components attached:

  • Capsule Collider With Physic Material:

    *Dynamic Friction: 0;
    *Static Friction: 0;
    *Bounciness: 0;
    *Friction Combine: Minimum;
    *Bounce Combine: Minimum;
    *Firction Direction 2: (0, 0, 0);
    *Dynamic Friction 2: 0;
    *Static Friction 2: 0;

  • Rigidbody:

    *Mass: 1;
    *Drag: 0;
    *Angular Drag: 0.05;
    *Use Gravity: true;
    *Is Kinematic: false;
    *Interpolation: None;
    *Collision Detection: Discrete;
    *Freeze Position: (0, 0, 1);
    *Freeze Rotation: (1, 1, 1);

  • And a Script with the following code:


    using UnityEngine;
    using System.Collections;
    
    public class SimplePhysicsTest : MonoBehaviour {
    	
    	public float moveForce = 20;
    	public float jumpForce = 300;
    	
    	[System.NonSerialized]
    	public bool grounded = false;
    	
    	void FixedUpdate () {
    		// Get Inputs
    		float moveInput = Input.GetAxis("Horizontal");
    		bool jumpInput = Input.GetButtonDown("Jump") || Input.GetKeyDown(KeyCode.UpArrow);
    		
    		
    		// apply movement
    		if(moveInput != 0) {
    			rigidbody.AddForce(Vector3.right*moveForce*moveInput);
    		}
    		
    		// apply jumping
    		if(jumpInput && grounded) {
    			MDebug.Print("jump force: "+jumpForce+"N @ "+MUnity.SecondsToString((int)Time.time));
    			rigidbody.AddForce(Vector3.up*jumpForce);
    		}
    		
    		MDebug.md.debugText = "Grounded: "+grounded;
    		
    	}
    	
    	
    	
    	// Checking if grounded
    	void OnCollisionEnter(Collision collision) {
    		if(IsGroundCollision(collision)) {
    			grounded = true;
    		}
    	}
    	void OnCollisionStay(Collision collision) {
    		if(IsGroundCollision(collision)) {
    			grounded = true;
    		}
    	}
    	void OnCollisionExit(Collision collision) {
    		if(IsGroundCollision(collision)) {
    			grounded = false;
    		}
    	}
    	bool IsGroundCollision(Collision collision) {
    		Vector3 mostGroundedPoint = Vector3.zero;
    		foreach(ContactPoint cp in collision.contacts) {
    			if(cp.normal.y > mostGroundedPoint.y) {
    				mostGroundedPoint = cp.normal;
    			}
    		}
    		return (mostGroundedPoint.y >= 0.5f);
    	}

}

There is nothing else to it other then the mesh render and unrelated stuff

The tiles are the default Cubes in unity with a material on it and they are positioned perfectly from each other ie: cube1 (0,0,0), cube2 (1,0,0), … etc

Can anyone tell me why he is not jumping the same height?

Note: (I don’t own the art in the game, I’m using it only to learn and I’m not going to publish this game)

i don`t know but the movement is jumpy
because you move by adding force to your rigidbody.

Why dont you use transform.Translate();?

and to achieve the slowing down effect you could use Matf.SmoothDamp();