I have been using this score system script without any problem in 3d. But when I tried to modify this script for my 2d game I am getting this error Script Error: OnCollisionEnter2D .
I dont know whats wrong with my code but I just need little help at here.
My 3d score code(Not Working)
var score = 0;
function OnTriggerEnter( other : Collider ) {
if (other.tag == "Coin") {
score += 1;
Destroy(other.gameObject);
}
}
function OnGUI () {
GUI.Label (Rect (20, 20, 200, 40), score + "");
}
My 2D score code(Not Working)
var point = 0;
function OnCollisionEnter2D( other : Collider ) {
if (other.tag == "Point") {
point += 1;
Destroy(other.gameObject);
}
}
function OnGUI () {
GUI.Label (Rect (70, 70, 200, 40), point + "");
}
Can someone tell me whats wrong with my 2d code?