Is there a way to set the force on an object in rigidbody2d, currently I'm using this but the speed constantly accelerates and decelerates.
void FixedUpdate()
{
if (direction.magnitude != 0)
{
rb.AddForce(direction / 10, ForceMode2D.Impulse);
}
else
{
rb.velocity = Vector2.zero;
}
}
↧