コード例 #1
0
    private void Shoot(BaseObject enemy)
    {
        TurretRotation tr = GetComponent <TurretRotation>();

        if ((tr == null || (tr != null && tr.IsRotationFinished())) && Time.time > fireRate + lastShotTimestamp)
        {
            lastShotTimestamp = Time.time;

            GameObject spawned   = Instantiate(this.bulletPrefab, projectilePosition.transform.position, projectilePosition.transform.rotation);
            GameObject explosion = Instantiate(this.explosionPrefab, projectilePosition.transform.position, projectilePosition.transform.rotation);
            spawned.GetComponent <Bullet>().Setup(enemy);
        }
    }