This is my code:
var rotSpeed: float = 90; // degrees per second
var coins : int;
function Awake()//initializes coins when game starts or restarts?
{
coins = 6;
}
function Update()//every frame, rotate
{
transform.Rotate(0, rotSpeed * Time.deltaTime, 0, Space.World);
}
function OnTriggerEnter(other: Collider)//if you touch the coin
{
Destroy(gameObject); // coin suicides
coins --;
Debug.Log(coins);
}
For some reason, coins is decreased once and then stays at five for the remaining five coins instead of decreasing each time I touch another coin. I don't understand how UnityScript works, but I've been trying at this for HOURS and it won't work.
What am I doing wrong?
↧