…
MyRigidbody.velocity = new Vector2(horizontal * movementSpeed, MyRigidbody.velocity.y);
Debug.Log("Ridigbody2D X velocity: " + MyRigidbody.velocity.x);
Debug.Log("Ridigbody2D Y velocity: " + MyRigidbody.velocity.y);
Debug.Log("Ridigbody2D X & Y velocity: " + MyRigidbody.velocity);
...
The code above always yields a Rigidbody2D.velocity.x value that matches the Rigidbody2D.velocity X value, but the Rigidbody2D.velocity.y value does not match the Rigidbody2D.velocity Y value while applying the new velocity. See console output below:
- Ridigbody2D X velocity: -1.491004
- Ridigbody2D Y velocity: -3.72529E-09
- Ridigbody2D X & Y velocity: (-1.5, 0.0)
- Ridigbody2D X velocity: -1.996178
- Ridigbody2D Y velocity: -1.862645E-09
- Ridigbody2D X & Y velocity: (-2.0, 0.0)
Any ideas why they are not matching? It obviously is not due to rounding.