Object drifting to left or right without reason
I'm making a 2D top-down shooter style game. I've gotten all the movement bits for the player down, but in it's current state after moving around for a while the player will start to drift left or right relative to the direction it's pointing. Things to note:
With the exception of rigidbody this is all hand-written code.
All of the positioning and rotation is being applied to the rigidbody instead of the transform.
I have turned off each script that dictates how the player behaves individually, and none of those things were the cause.
The inputs are not returning unwanted values and no joysticks are plugged in.
This behavior will temporarily stop if it bumps up against a wall in the direction it's moving.
The controls are to move up/down/left/right relative to the screen, and not the object. The object however is moving relative to it's direction.
This one's a doozy.
Answer by abledbody · Jan 17, 2016 at 04:15 AM
Found the solution, the rigidbody was rotating even though it didn't look like it, which caused phantom forces. A simple rb.angularVelocity = Vector3(0,0,0); fixed that right up.
Thank you very much, this solved a similar problem I was also experiencing.