Sent when an incoming collider makes contact with this object's collider (2D physics only).
function OnCollisionEnter2D(coll: Collision2D) { if (coll.gameObject.tag == "Enemy") coll.gameObject.SendMessage("ApplyDamage", 10); }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Enemy") coll.gameObject.SendMessage("ApplyDamage", 10); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def OnCollisionEnter2D(coll as Collision2D) as void: if coll.gameObject.tag == 'Enemy': coll.gameObject.SendMessage('ApplyDamage', 10)