- Home /
Question by
wegaz · Jun 02, 2014 at 08:03 PM ·
javascriptcollisiontriggerscore
Whats wrong with my score script
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?
Comment
Your answer
Follow this Question
Related Questions
Collision with renderer.enabled? 0 Answers
Having problems with 2d collision triggers (javascript) 1 Answer
Adds too many points to the score? 0 Answers
How to add the right amount of points when my player destroys a gameobject? 0 Answers
Error(non static member): using public variable from other script JS 1 Answer