Question by
unity_QTYQkCu8ZY5NCg · Feb 05, 2021 at 12:51 PM ·
3dobjectdestroy
(3d) Destroy a GameObject when player walks over it
Hey im new to Unity and C#. I will ask if there are anybody who know how i can Destroy a GameObject when my player walk over it or stand on it?
Comment
Answer by Vohry · Feb 05, 2021 at 03:41 PM
Create collider on both objects. If you want collision with this object add OnCollisionEnter to detection object and inside method destroy player GameObject, look here: https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html But if you want to create invisible trigger GameObject, just tick IsTrigger property in RigidBody and then implement method OnTriggerEnter and inside it destroy GameObject , look here: https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html