In this video we see how to check if a GameObject has a certain component assign to it in Unity, this allows us to execute certain actions only if a certain Component is present.
In this example we detect the collision between two spheres and a plane, one of the spheres has a Player scripts and the other an Enemy script, if the ball has a Player script we are going to the destroy it and if the ball has the Enemy script we are going to make it bounce.
Check if a GameObject has a component is also important to prevent the null reference exception, an error that happens if we try to use a variable that is null.
____________________________________________________________
*PORTFOLIO:*
*CONTACT:*
*LINKEDIN:*
*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
____________________________________________________________