Collect Items For Points

Hi

I have character walking around in a 2D environment. I would like him to be able to collect objects of some sort for points.

Example, like Super Mario collecting coins in the game.

How can I go about doing this?

Thanks, Chris

Make sure your coin objects have a collider *(a sphere collider is probably sufficient, and is the cheapest type), and make sure the collider is set to be a "Trigger". (scroll down to the section on triggers on that page).

Next, make sure all your coins are tagged as "Coin".

Finally add a script on your player which detects whether a trigger has been touched, and whether that trigger is tagged with "Coin", and if so, increment your score variable. This script can also remove the coin object at the same time. Something like this:

var score = 0;

function OnTriggerEnter( other : Collider ) {
    if (other.tag == "Coin") {
        score += 5;
        Destroy(other.gameObject);
    }
}

It didn't work for me when I used this Useful bit of info. the script didn't work. it said: Function: not Applicable. What should I do? please help, because I am working on a game and I too would: A- want to play a sound B- add a point meter. I would appreciate the help.

Nick I've a solution. Just do some texture and change it when u destroy any item.

anybody can suggest an easy solution, to display the score onscreen?

I've searched around the net, but none of the solutions worked