I am making an Android game, and when the player touches a coin, it adds it to the score and destroys the coin object. But the code refuses to work, and I don’t know why. The coin has a mesh collider on it, and I thought maybe that was the issue. So I tweaked the code to detect rocks instead, which have sphere colliders on. Still no luck.
var PlayerCoins : int;
var CoinText = "Coins: " + PlayerCoins;
function OnTriggerEnter(other : Collider)
{
if(other.tag == "coin")
{
PlayerCoins +=1;
CoinText = "Coins: " + PlayerCoins;
Destroy(other.gameObject);
}
}