Question by
ngerbens · Jul 12, 2021 at 02:10 PM ·
jumpjumpingforcejumping object
Why does AddForce have various results?
My object jumps with Impulse AddForce, but sometimes it makes my player (0.2 units tall) jump extremely high (2 units) and sometimes it jumps very close to the ground (0.1 units). I know the offset is variable (on purpose so the object rotates in the air), but the force also varies when my object in the same position. Any idea how and why?
public float jumpSpeed = 4;
public float jumpOffset = 20;
if (Input.GetButtonDown("X") && isGrounded && currentSpeed < 0.01f)
{
Vector3 direction = new Vector3(0, 1, 0);
rb.AddForceAtPosition(direction * jumpSpeed, transform.position - cam /jumpOffset, ForceMode.Impulse);
}
Comment