unity-game-enginecollider

How to find which side of a collider has been hit


Hi Guyz I could`nt Find a way How to find which side of a collider has been hit........ I have a car and its contain box collider...... And I want is when the other car hit my car then I will add some forces.... but first I need to detect which side of the car hit......

Hi Guyz I could`nt Find a way How to find which side of a collider has been hit........ I have a car and its contain box collider...... And I want is when the other car hit my car then I will add some forces.... but first I need to detect which side of the car hit......


Solution

  • I solve it through this code

       Oncollisionenter
       Vector3 dir = collision.tranform.position - transfrom.position;
       Getcomponent<RigidBody>().AddForce(dir *50)