Exemple #1
0
    private void Update()
    {
        if (combatBehaviour.targetAcquired)
        {
            turretRotation.SetIdle(false);

            var currentTarget = combatBehaviour.target;
            var distance      = (transform.position - currentTarget.position).magnitude;

            if (distance <= combatBehaviour.combatStats.range)
            {
                turretRotation.SetAimpoint(currentTarget.position);

                if (turretRotation.IsLineOfSight() && !isLaunching)
                {
                    StartCoroutine(launchMissile());
                }
            }
        }
        else
        {
            turretRotation.SetIdle(true);
        }
    }
Exemple #2
0
    private void Update()
    {
        if (combatBehaviour.targetAcquired)
        {
            turretRotation.SetIdle(false);

            var currentTarget = combatBehaviour.target;
            var distance      = (transform.position - currentTarget.position).magnitude;

            if (distance <= combatStat.range)
            {
                turretRotation.SetAimpoint(currentTarget.position);

                if (turretRotation.IsLineOfSight() && !isFiring && combatBehaviour.isAttacking)
                {
                    StartCoroutine(FireBullets());
                }
            }
        }
        else
        {
            turretRotation.SetIdle(true);
        }
    }