Detect collision and prevent intersection

I m trying to detect the collision of two objects (Player and Rock) I want to be able to handle the collision event (OnTriggerEnter) but also prevent the objects from intersecting.


  1. the player runs into the rock,
  2. the rock knows its the player (OnTriggerEnter or similar)
  3. The player cannot move through the rock, stops right at it’s edge as if trying to walk through a wall
  4. The rock does not move

I have tried all variations of Is Trigger, Is Kinematic and both objects have rigid bodies attached but the closest I get is one of the objects spinning off into the abyss. I have even tried using OnTriggerEnter and OnTriggerStay to set the position of the player to the position it was at when the collision first occurred which works but looks like ass.

How can I detect the collision in my script but keep both objects from driving over/through each other?

Thank you very much for any help!

You mean like OnCollisionEnter? Just don’t use trigger and make sure to use a collider on both objects. The player needs to have a rigidbody and be completely controlled by physics (stay away from transform.position and translate).