I stop gameobjects from colliding with one another by having box colliders around the gameobjects with dimensions bigger than the gameobjects. It works fine, but I want that when the gameobjects collide with one another, they stop moving. I cannot use OnTriggerEnter as I have turned IsTrigger off. Is there a thing which can determine when two gameobjects' collider touch each other?
1 Answer
OnCollisionEnter(Collision collision)
fires when two colliders enter collision (similar to OnTriggerEnter
but for non-trigger interactions), provided that the moving collider has a Rigidbody attached.
You can also use Physics.CheckBox / Physics.OverlapBox / Physics.OverlapBoxNonAlloc to scan for overlaps in a given prism of space, if you want to manage the physics yourself.