Question by
connorgoan · Aug 28, 2021 at 09:38 AM ·
physicsframerate
AddForce depends on frame rate?
I am using AddForce to make my character jump, but it jumps much higher when I run it with lower frame rates. I found similar problems that were solved by using FixedUpdate, but it does not help. Here is the relevant code:
void Update()
{
if (xform.position.y < 0.5 && Input.GetKeyDown("space"))
{
jump = true;
}
else if (xform.position.y < 0.5 && Input.touchCount > 0)
{
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
jump = true;
}
}
}
void FixedUpdate()
{
if (jump == true)
{
rbody.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);
jump = false;
}
}
Comment