Пример #1
0
    void Update()
    {
        Vector2 gunPosition = gunObject.transform.position;

        float secondsSinceLastFired = Time.time - timeLastFired;

        // Only fire once every firingIntervalInSeconds seconds
        if (secondsSinceLastFired > firingIntervalInSeconds)
        {
            timeLastFired = Time.time;

            // Can we actually hit the player if we shoot?
            if (detectPlayer.PlayerVisible())
            {
                FireBullet(gunPosition, detectPlayer.GetDirectionToPlayer());
            }
            else
            {
                StopFiring();
            }
        }
    }