- Home /
Question by
Rimoldi · Feb 16, 2019 at 04:54 PM ·
2drigidbody2dvelocityaddforce2d-physics
Rigidbody2D.velocity.x not working but Y does
This code is suposed to add a force on the X axis every time I press SHIFT, but it just doesn't work, and if I try Vector2.up instead of Vector2.right it works, I don't understand why this is happening, but the velocity on the X axis is not working properly, can someone explain?
void Update()
{
if (Input.GetButton("Fire3"))
{
rb.AddForce(Vector2.right * force * Mathf.Sign(transform.localScale.x), ForceMode2D.Impulse);
}
}
Comment