Rigidybody2D addforce at constant speed

Attempting an infinite 2d runner, but when I use rigibody2D.addforce it slowly accelerates to insanely fast regardless of what I multiply it by…

enter code here#pragma strict

var myForce : float = 20;
var jumpForce : float = 600;


function Update()
        {
          if(Input.GetKeyDown(KeyCode.Space))
        	{
            rigidbody2D.AddForce(new Vector2(0, jumpForce ));
        	}
        }


function FixedUpdate () {

		rigidbody2D.AddForce(new Vector2(myForce, 0));

};

Even if I change myForce to 10 it starts slowly and eventually picks up crazy amounts of speed. All I want is a constant movement speed. Thanks in advance.

1 Answer

1

I believe rigidbody.Addforce() adds the force to the current velocity, meaning you actually speed up your game object by “myForce” every time fixed update is called. Try calling it only once

The character needs to be constantly moving, when I call it once, he moves forward then stops...