filmov
tv
How to DETECT COLLISIONS BETWEEN TWO OBJECTS in Unity - OnCollision events
![preview_player](https://i.ytimg.com/vi/bukNHwYH85Q/maxresdefault.jpg)
Показать описание
In this video we see how to detect collisions in Unity using scripts, but before go further with the code part we need to make sure that the objects that are going to collide have Collider components assigned and also at least one of them has a Rigidbody component assigned to it.
The script that detect the collision has to be assigned to one (or both) of the GameObjects that has a Collider and that is going to collide.
If all the previous conditions are met, Unity will automatically call a couple special functions inside our script.
In particular we are interesed in the "OnCollisionEnter", "OnCollisionStay" and "OnCollisionExit" functions.
____________________________________________________________
*DONATIONS*
-You can download one of me free assets for Unity from my ITCH page and leave a donation
-You can donate with the THANKS button on every video
____________________________________________________________
The script that detect the collision has to be assigned to one (or both) of the GameObjects that has a Collider and that is going to collide.
If all the previous conditions are met, Unity will automatically call a couple special functions inside our script.
In particular we are interesed in the "OnCollisionEnter", "OnCollisionStay" and "OnCollisionExit" functions.
____________________________________________________________
*DONATIONS*
-You can download one of me free assets for Unity from my ITCH page and leave a donation
-You can donate with the THANKS button on every video
____________________________________________________________