Exemple #1
0
    bool Look(AiController controller)
    {
        Vector3[] targets = new Vector3[2] {
            controller.GetPlayerPosition(), controller.GetBunkerPosition()
        };

        if (controller.PlayerInFov)
        {
            foreach (Vector3 target in targets)
            {
                var   inDirection = target - controller.Shooting.Muzzle.position;
                float angle       = Vector3.Angle(target - controller.Shooting.Muzzle.position, controller.Shooting.Muzzle.forward);
                if (angle > -(viewAngle / 2) && angle < viewAngle / 2)
                {
                    if (Physics.Raycast(controller.Shooting.Muzzle.position, inDirection, out RaycastHit hit, 999, layerMask))
                    {
                        if (hit.transform.tag == "Player")
                        {
                            controller.chaseTarget = hit.transform.gameObject;
                            return(true);
                        }
                    }
                }
            }
        }
        return(false);
    }
Exemple #2
0
    void Search(AiController controller)
    {
        //controller.Movement.Agent.stoppingDistance = 0;
        Vector3 lastSeenAt = controller.GetLastSeenPosition();

        controller.Movement.MoveTo(lastSeenAt);
        if (!controller.Movement.IsMoving())
        {
            controller.Shooting.Aim(controller.GetPlayerPosition());
        }
    }