Basically Notoriety. Check out that game btw. When NPC look at you that detect you, but if you behind a wall, they don't detect players.
I tried making a hat for the NPCs that will touch a player if he/she is in the NPCs sight. But it goes through walls so that doesn't work.
Please help me. I have no idea what to do, iv been thinking about this for more than a year.
you can use camera.GetPartsObscuringTarget()
more here
You can raycast from the NPC's head to the target, if it hits a body part belonging to them, then the NPC sees them.
1 | local maximumDistance = 300 -- the ray's max distance, in studs |
2 | local ray = Ray.new(NPC.Head.Position, (TARGET.HumanoidRootPart.Position - NPC.Head.Position).Unit * maximumDistance) |
3 | local hit = workspace:FindPartOnRayWithIgnoreList(ray, { NPC } ) |
4 |
5 | if hit.Parent = = target.Parent then |
6 | print ( "i can see the player" ) |
7 | else |
8 | print ( "i cannot see the player" ) |
9 | end |
Keep in mind that I haven't tested the code above, so it may need some tweaking.