collision detection between two players in unity code example
Example 1: unity how to make two objects not collide
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "theobjectToIgnore")
{
Physics.IgnoreCollision(theobjectToIgnore.collider, collider);
}
Example 2: check for collision unity c#
void OnCollisionEnter(Collision col) { }
Example 3: how to do collision tag in unity
void OnColliSionEnter2D(Collision col){
if (col.gameobject.tag == "Enemy"){
Destroy(gameObject)
}
}