public Vector3 MoveLogic(EnemyController enemy, GameObject player)
    {
        float dist = LMHelper.GetDistance(enemy, player);
        Vector3 mvt = new Vector3(0f, 0f, 0f);
        enemy.SetStationary(true);

        // Aggro if in range
        if (dist <= enemy.GetAggroRadius())
        {
            enemy.SetAggroState(true);
        }
        else {
            enemy.SetAggroState(false);
        }
        return mvt;
    }
    public Vector3 MoveLogic(EnemyController enemy, GameObject player)
    {
        float dist = LMHelper.GetDistance(enemy, player);
        Vector3 mvt = new Vector3(0f, 0f, 0f);

        // If in aggro range, set aggro state to true
        if (dist <= enemy.GetAggroRadius())
        {
            enemy.SetAggroState(true);

            //if not already strafing or reached strafe target, setup new one
            if (Strafing == false || distST < 5) {
                Strafing = true;

                //Raycast out in direction of player
                Vector3 dir = LMHelper.BaseMoveLogic(enemy, player);
                this.transform.forward = dir;
                RaycastHit hit;
                float tdist = 0;
                if (Physics.Raycast(this.transform.position, dir, out hit))
                {
                    tdist = hit.distance;
                }
                StrafeTarget = this.transform.position + dir * tdist;
                mvt = dir;
            }

            //else, continue along strafing path towards target
            else
            {
                mvt = (StrafeTarget - this.transform.position).normalized;
            }

        }
        else {
            enemy.SetAggroState(false);
            Strafing = false;
        }

        //Debug.Log(Strafing + "," + StrafeTarget + "," + mvt);

        return mvt;
    }
    public Vector3 MoveLogic(EnemyController enemy, GameObject player)
    {
        float dist = LMHelper.GetDistance(enemy, player);
        float optrng = enemy.GetOptimalRange();
        float delta = dist - optrng;    //difference from optimal range
        Vector3 mvt = new Vector3(0f, 0f, 0f);

        // If out of range, move into range
        if (dist <= enemy.GetAggroRadius())
        {
            enemy.SetAggroState(true);
            if (delta > 0) {
                mvt = LMHelper.BaseMoveLogic(enemy, player);
                mvt *= delta / (1.5f * optrng);
            }
        }
        else {
            enemy.SetAggroState(false);
        }
        return mvt;
    }
예제 #4
0
 //Checks whether target is in range
 public static bool IsInRange(EnemyController enemy, GameObject player)
 {
     float dist = GetDistance(enemy, player);
     return dist <= enemy.GetAggroRadius();
 }