コード例 #1
0
    // Start is called on initialization
    void Start()
    {
        // Get reference to our tank script
        tankScript = GetComponent <TankScript> ();

        // Start out with the firing on cooldown
        fireCooldown = fireFrequency;

        // Make the tank turn right all the time
        tankScript.SetTurnSpeed(1);
        tankScript.SetSpeed(1);
    }
コード例 #2
0
    // Start is called on initialization
    void Start()
    {
        // Get reference to our tank script
        tankScript = GetComponent<TankScript> ();

        // Start out with the firing on cooldown
        fireCooldown = fireFrequency;

        // Make the tank turn right all the time
        tankScript.SetTurnSpeed (1);
        tankScript.SetSpeed (1);
    }
コード例 #3
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();
        }
    }