Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity destroy object on collision

void OnCollisionEnter2D(Collision2D coll)
}
   // Check if we have collided with the enemy
   if (coll.gameObject.tag == "Enemy")
   {
      Destroy(coll.gameObject);     
   }
}
Comment

Unity Destroy gameObject upon collision

void OnCollisionEnter2D(Collision2D collision)
{
    Destroy(gameOnject);
}

// Or if you only want it to be destroyed when 
// hitting something specific

void OnCollisionEnter2D(Collision2D collision)
{
    if(collision.gameObject.tag == "tag")
    {
         Destroy(gameObject);
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: add mime type for woff in web.config 
Csharp :: how to use the mouse scroll wheel to move the camera in unity 
Csharp :: unity event 
Csharp :: .net mvc decimal displayformat currency 
Csharp :: convert list to ienumerable 
Csharp :: get char lowercase in c# 
Csharp :: c# enum to int array 
Csharp :: nested dictionary c# 
Csharp :: c# save pdf to folder 
Csharp :: c# byte 
Csharp :: see if two string arrays are equal c# 
Csharp :: how to convert float to int c# 
Csharp :: c# regex find number in string 
Csharp :: c# get list of all class fields 
Csharp :: c# if int is in range 
Csharp :: c# main 
Csharp :: c# get directory name from filename 
Csharp :: split string on last element 
Csharp :: change image of button c# 
Csharp :: C# program that joins List of strings 
Csharp :: how to create empty text file in c# 
Csharp :: sorting a list of objects in c# 
Csharp :: c# remove word from string 
Csharp :: c# radio button checked 
Csharp :: c# how to check if a array bool is all true 
Csharp :: unity 2d 
Csharp :: disable button in android studio 
Csharp :: contains duplicate 
Csharp :: c# get function name 
Csharp :: c# swap name in string 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =