- Home /
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.
Answer by recon472 · Oct 07, 2014 at 10:45 AM
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...
Your answer
Follow this Question
Related Questions
Not understanding how rigidbody2D.AddForce works 0 Answers
Unity 2D addforce problem 1 Answer
AddForce from Two Sources 1 Answer
Dashing with rigidbody2D not working right 2 Answers
move 2d character affected by physics with velocity and/or add force 2 Answers