Hi. I’m very new to Unity and I’ve a question about collecting items in my game…
I got 10 items in my game, when the player needs to click on them, or walk into them to trigger some events.
What I want next is to create a counter that counts how many items the player has clicked/walked into.
when the counter counts to 10 something will happen…(like fireworks)
I’m able to make it count for entering the trigger, but not for mouse clicks…
This is the script I got on the first person controller
var score = 0;
var scoreText = “Items viewed: 0”;
var f : Font;
var fontSize : int = 20;
function OnTriggerEnter(other : Collider ) {
if (other.tag == "counter") {
score += 1;
scoreText = "Items viewed: " + score;
Debug.Log("Score is now " + score);
}
}
function OnGUI () {
GUI.skin.font = f;
GUI.skin.label.fontSize = fontSize;
GUI.Label (Rect (200, 10, 200, 400), scoreText.ToString());
}
I have a tag called “counter” for all the 10 items.
How can I get the counter also counts the mouse clicks?
Thanks for your time.