Hi
I am trying to make a rigidbody player and I can’t get the jump right. I change the velocity of the rigidbody but the jump height is sometimes different. What am I doing wrong?
void FixedUpdate()
{
float gravity = rig.velocity.y + extraGravity * Time.fixedDeltaTime;
rig.MovePosition(rig.position + new Vector3(moveDirection.x, gravity, moveDirection.z) * Time.deltaTime);
if (Input.GetKeyDown(KeyCode.Space))
{
if (isGrounded)
{
rig.velocity = new Vector3(rig.velocity.x, jumpSpeed, rig.velocity.z);
}
}
}
Any help is appreciated.