// Update runs every frame void Update() { // Fire a bullet if we've waited for the duration of the cooldown fireCooldown -= Time.deltaTime; if (fireCooldown <= 0) { fireCooldown += fireFrequency; tankScript.Fire(); } }
// Update is called every frame void Update() { // Use horizontal input to set turn speed float x = Input.GetAxis("Horizontal"); tankScript.SetTurnSpeed(x); // Use vertical input to set forward/backward speed float y = Input.GetAxis("Vertical"); tankScript.SetSpeed(y); // If we pressed the fire button, fire! if (Input.GetButtonDown("Fire1")) { tankScript.Fire(); } }