unity delete object code example

Example 1: unity remove gameobject

// To remove a GameObject use the function 'Destroy()'
Destroy(gameObject);

Example 2: destroy gameobject unity

Destroy(this.gameObject);

Example 3: how to destroy a gameobject in c#

Destroy(gameObject); // destroys the game object attached to the script

Example 4: how to destroy a gameobject after some hits in unity 3d

void OnCollisionEnter(Collision YourGameobjectasAVarable) {   if(YourGameobjectasAVarable.collider.tag == "YourGameObject'sTag")         {             //Whatever you want to happen, in your case you want it to be destroyed             Destroy(//Your game object//*)         }

Example 5: how to destroy a gameobject after some hits in unity 3d

void OnCollisionEnter(Collision other)  {      hit += 1;      checkhit();  }