示例#1
0
    public void UseExplosive()
    {
        fireTime += Time.deltaTime;

        // time to fire
        if (fireTime > fireRate)
        {
            //Create projectile instance
            GameObject projectileGO = Instantiate(explosivePrefab, turretFirePoint.position, turretFirePoint.rotation);

            //Get the script from the bullet GameObject
            TurretProjectileManagerV3 projectile = projectileGO.GetComponent <TurretProjectileManagerV3>();

            if (projectile != null)
            {
                projectile.Seek(turretTarget);
            }
            else
            {
                return;
            }

            turretAudioSource.clip = explosiveFire;

            turretAudioSource.Play();

            //Create particle effect at turretFirePoint
            GameObject newMuzzleBlast = Instantiate(muzzleBlast, turretFirePoint.position, turretFirePoint.rotation);

            //Destroy the particle effect based on the turrets fireRate
            Destroy(newMuzzleBlast, fireRate);

            // reset fire time
            fireTime = 0.0f;
        }
    }
示例#2
0
 void OnEnable()
 {
     projectileRef = (TurretProjectileManagerV3)target;
 }