예제 #1
0
    override protected void Update()
    {
        // Move
        base.Update();

        // Once at the target, fire periodically
        if (SquadReady())
        {
            if (timer.Update(Time.deltaTime))
            {
                // Fire a shot
                GameObject bulletObj = GameObject.Instantiate(missilePrefab);
                bulletObj.transform.position = transform.position;

                Missile missile = bulletObj.GetComponent <Missile>();
                missile.Launch(transform.forward * 15.0f);
            }
        }
    }
예제 #2
0
    override protected void Update()
    {
        // Move
        base.Update();

        // Once at the target, fire periodically
        if (SquadReady())
        {
            if (timer.Update(Time.deltaTime))
            {
                // Fire a shot
                for (int i = 0; i < 2; i++)
                {
                    float sign = (i * 2.0f) - 1.0f;

                    GameObject bulletObj = GameObject.Instantiate(bulletPrefab);
                    bulletObj.transform.position = transform.position + new Vector3(sign * 2.0f, 0.0f, 0.0f);

                    Bullet bullet = bulletObj.GetComponent <Bullet>();
                    bullet.velocity = new Vector3(shotDirection.x * sign, shotDirection.y, shotDirection.z) * 20.0f;
                }
            }
        }
    }