Make a script like this:
function OnTriggerEnter (other : Collider)
{
if(other.gameObject.tag == "Player")
{
other.gameObject.SendMessage ("ApplyScore", incomingScoreValue);
GameObject.Destroy(gameObject);
}
}
And attach is to the boxes.
Then on any of the player's scripts you put a function like this:
function ApplyScore(incomingScore:int)
{
//do whatever you want with the score
}
↧