I recently added a rigidbody to my gameobject so that I can recieve ontriggerenter/exit calls. Though if my new unit hits something else with a collider some odd behavior occurs.
Whats causing this to happen? And how do I stop the object from moving in a seemingly unpredictable way if it hits another collider?
As stated in the comments to the original question, locking the axis will prevent this from happening. The reason your gameObject moves around when it gets hit is because “Rigidbody” is a component, that tells the object it is attached to, to simulate Physics when it interacts with another collider. If you don’t want to simulate Physics, you can use other methods of detecting collision, or you can lock all of the axes.
However, it is recommended that if your object is moving and attempting to detect collision, that you have a Rigidbody component on it at all times. I believe this is because rigidbodies detect collision using FixedUpdate instead of Update, which is more exact and will give you a more accurate collision setup.