Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to know what object player touches unity 2D

/* 
For this to work, both objects (Player and something that it touches) must have
Any Collider2D component enabled
*/
// If none of them have trigger on.
void OnCollisionEnter2D(Collision2D other)
{//this is how to get name of the other object
	string otherObjectName = other.gameObject.name;
 //this is how to get tag of the other object
  	string otherObjectTag = other.gameObject.tag;
}
// If at least one of them has Trigger on, use this function instead.
void OnTriggerEnter2D(Collider2D other){

}
Comment

PREVIOUS NEXT
Code Example
Csharp :: remove element from sting array c# 
Csharp :: c# get path without filename 
Csharp :: object list to csv c# 
Csharp :: detect keypress c# 
Csharp :: C# delete last enviroment new line 
Csharp :: renaming table name entity framework code first fluent api 
Csharp :: ask for administrative permission 
Csharp :: solution to fizzbuzz c# 
Csharp :: save file dialog filter c# 
Csharp :: how create another new app file in laravel 
Csharp :: c# separate string by comma 
Csharp :: emboss button in android app 
Csharp :: c# + longest streak in strings 
Csharp :: round double c# 
Csharp :: how to have is trigger on but also have collisions 
Csharp :: formula text and/or netsuite 
Csharp :: c# retrieve files in folder 
Csharp :: public GameObject 
Csharp :: c# string to hex 
Csharp :: how to add a list to observablecollection in c# 
Csharp :: run linux command in c# 
Csharp :: c# pick a random item from array 
Csharp :: unity set material 
Csharp :: update models with ef core 
Csharp :: replace double backslash with single backslash c# 
Csharp :: shuffle arraylist c# 
Csharp :: c# get the last item in a list 
Csharp :: unity new input system keydown 
Csharp :: visual studio fix formatting 
Csharp :: javascript close page after 5 seconds 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =