1. Hi I know most plugins are using a Raycast to get directly the target in front of them (specific line), but im trying to use a cone vision just like NPCs with a 180 degree forward (-0.5f cone?) as well as up and down 180. I assumed it's doable within a Spherecast (not just lineair) but im having a hard time finding the correct formula for the cone check. Can you help me? I've looked at https://docs.unity3d.com/ScriptReference/Physics.RaycastAll.html and Guntraps examples, and other plugins like HumanNPC but still can't make it work. They either have a 360 degree check or direct line check (have to stand right in the line facing to be targetted). Or is it with Raycast, RaycastAll, Spherecast, Spherecastall, Linecast, Vis<Entities> ? Thanks
     
  2. SOLVED: If you want to use it, works pretty well (almost very accurate eye to eye contact). Im not an experienced dev, im sure u can have it better. Like if you agree about it?
    Code:
    private static bool CanSee(NPCPlayer npcPlayer, BasePlayer target)
            {
                NPCPlayerApex source = npcPlayer as NPCPlayerApex;
                 RaycastHit raycastHit;
                 var pos = source.eyes.position + source.GetOffset();
                 var rayDirection = (target.transform.position + target.GetOffset() - new Vector3(0, 0.7f, 0)) - source.eyes.position;             if (Vector3.Distance(source.transform.position, target.transform.position) < 1f) // really close (front or behind), CanSee = true. If you want npc to hate being approached from too close
                     return true;
                 if (Vector3.Angle(rayDirection, source.eyes.HeadForward()) < 90f) // in the 180 front cone, CanSee = true
                 { // Detect if player is within the field of view
                     if (Physics.Raycast(pos, rayDirection, out raycastHit))
                     {
                         if (raycastHit.GetCollider().GetComponent<BasePlayer>() == target)
                             return true;
                     }
                 }
                 return false;
            }