Need Example for Collision Detector

Can someone give me an example project for Collision Detect?

Search anything about this in Google wasn’t work.

The collision that I figure is, there are 2 box, Box A is static, and Box B is dynamic and above, when Game start, Box B will fall, when Box B touch Box A, Box B stop fall, and Console will show Collision Detected.

This was very easy, but I really don’t know how they work.

This should hopefully clarify collision detection for you. I recommend going through all the modules - the site really helped me out.

You probably won’t find specific projects about collisions - it’s better to create your own test project.

Basically, the several events related to collisions and triggers are as follows:

1- OnCollision events occur only when a rigidbody hits a collider or CharacterController. They may also occur when a collider hits a rigidbody, but only if the rigidbody is awake. OnCollision events are sent to scripts attached to both, the rigidbody and the other object.

2- OnTrigger events occur when a rigidbody or CharacterController touches a static trigger. If you add a kinematic rigidbody to the trigger, OnTrigger events will also occur when the trigger moves and touches any collider. OnTrigger events are sent to scripts attached to both, the trigger and the other object.

3- OnControllerColliderHit events occur when a CharacterController hits any collider, but not when it hits another CharacterController (weird as this may seem, no events are generated for collisions between CharacterControllers!). This event occurs all the time due to the contact with the ground, thus a common providence is to filter out collisions from below (return when hit.normal.y > 0.95, for instance). OnControllerColliderHit events are sent only to the CharacterController scripts.

NOTE: As a rule of thumb, don’t move things with Translate or other Transform functions if you want correct collision detection: only move rigidbodies with forces or by directly setting their velocities, and CharacterControllers with Move or SimpleMove.