Esempio n. 1
0
 // 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();
     }
 }
Esempio n. 2
0
    // 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();
        }
    }