Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Destroy GameObject with Tag Unity

    //private void OnCollisionEnter ( Collision collision )
    //{
    //    if ( collision.collider.CompareTag ( "Player" ) )
    //    {
    //        Destroy ( collision.gameObject , 0.1f );
    //    }
    //}
    private void OnTriggerEnter ( Collider other )
    {
    //Box collider is triggered...Top Script box collider is nopt triggered
        if(other.CompareTag ("Player") )
        {
            //Destroy Colliding game Object

            Destroy ( this.gameObject );

            //Destroy other game objject to which collided

            Destroy ( other.gameObject );
        }
    }
 
PREVIOUS NEXT
Tagged: #Destroy #GameObject #Tag #Unity
ADD COMMENT
Topic
Name
4+8 =