on collision enter 2d code example
Example 1: unity oncollisionenter2d
void OnCollisionEnter2D(Collision2D col)
{
Debug.Log("Collided");
}
Example 2: oncollisionenter2d
using UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour {
void OnCollisionEnter2D(Collision2D coll) {
if (coll.gameObject.tag == "Enemy")
coll.gameObject.SendMessage("ApplyDamage", 10);
}
}
Example 3: on collision enter 2d unity
void OnCollisionEnter2D(Collision2D col)
{
Debug.Log("OnCollisionEnter2D");
}
Example 4: collision detector unity c# 2d
void OnCollisionEnter2D(Collision2D coll){)