I’m trying to give the player control over the rate of spawn of the 'ballClone’s by pressing shift and - (_) to decrease and shift and = (+) to increase.
But it has no effect in the game, although there are no errors
var rate = 1.0;
var ball : Rigidbody;
private var tick = 0.0;
function Update () {
if (Time.time > tick)
{
tick = Time.time + rate;
var ballClone : Rigidbody = Instantiate(ball, Vector3(0,12,0),Quaternion.identity);
}
if (Input.GetKeyDown("_"))
{
rate = rate - 0.1;
}
if (Input.GetKeyDown("+"))
{
rate = rate + 0.1;
}
}
thought it would be simple, but I’m pretty stuck. Any ideas whats wrong?
It's the logic OR, and yes, you can think of it as an either clause. There also exists &&, the logic AND: you could think of it as both (or all, if there are more conditions).
– aldonaletto