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 :: random character c# 
Csharp :: c# conver date utc to cst 
Csharp :: get all assemblies c# 
Csharp :: unity invisible cube 
Csharp :: add items to listbox from text file c# 
Csharp :: text not centered winforms button 
Csharp :: How to Create Hint, PlaceHolder Text, Watermark In a TextBox vb.net 
Csharp :: c# get property using string 
Csharp :: validate base64 string c# 
Csharp :: unity how to ommit letters from a string 
Csharp :: c# get calling method name 
Csharp :: materials pink in unity 
Csharp :: how to show a reference in unity 
Csharp :: gravity script unity 
Csharp :: check if panel has controler c# 
Csharp :: object list to csv c# 
Csharp :: meta keywords tag mvc .net core 
Csharp :: unity put children in list 
Csharp :: delete all dir content c# 
Csharp :: assign long value c# 
Csharp :: change textbox text color c# 
Csharp :: how to have is trigger on but also have collisions 
Csharp :: nearest greater to right 
Csharp :: get directory name of path c# 
Csharp :: c# round number 
Csharp :: c# iterate over a dictionary 
Csharp :: merge point of two list 
Csharp :: c# append textbox 
Csharp :: c# how many lines in methods 
Csharp :: c# groupby date 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =