as the distance of the target from the origin increases, the field of view boundaries increases. this is a directly proportional relation. as this distance D increases let there be two vector2 values, C which denotes the maximum boundary, and T which denotes the minimum boundary. let B be D divided by the maximum distance the npc can see, yielding a [0,1] value and the limitation is that the target must be in front of the origin.
let H be a value which influences how much B is multiplied by
let G be B*H
as B changes, C = v2(G, G), T = v2(-G, -G). you can take the relative position of the target from the origin and check if the targets position is within T and C based on the targets X and Y position
bruh its fine it doesn’t matter as long as it works and isn’t unreadable
It’s just a small nitpick. I’m not attacking them, I’m just sharing my thoughts.
(post deleted by author)
(post deleted by author)
if you mean generalized iteration, it is fairly new to luau, being introduced a year ago, and should be used over an iterator such as next or iterator function such as pairs
(post deleted by author)
(post deleted by author)
I thought this line should be FOV/2 and Guard = NPC.
But your code is great. Thanks.
if Angle <= FOV/2 and Distance <= Range and CheckLineOfSight(NPC.Head.Position, Character.Head.Position) then
(post deleted by author)
Thanks for your feedback.
I see that:
- The main center line is the Lookvector of the NPC’s face.
- So the angle from the center line to the limits will be FOV/2
- Currently we are calculating the angle between the lookvector and the vector connecting the face of the NPC and the player’s face, so we will compare it with FOV/2
- Since the heights of the NPC’s head and the player’s head are different, I think it’s a good idea to remove the y component by multiplying the vectors by vector3.new(1,0,1) and then comparing in the xz plane would be more accurate.
Here it is assumed that the NPC is always looking sideways (not looking up or down).
local NPCToCharacterFlatten = NPCToCharacter * vector3.new(1,0,1)
local NPCLookVectorFlatten = NPCLookVector * vector3.new(1,0,1)
local DotProduct = NPCToCharacterFlatten:Dot(NPCLookVectorFlatten)
(post deleted by author)
Wait can I ask,I want to check if a dead body/corpse is in the vision so I can make like withnessers. How do I do that?
(post deleted by author)
(post deleted by author)
Hello everyone! I completely rewrote this tutorial with better code and a cleaner layout.
Hi,
Can you provide a .rbxl or editable demo place?
Thanks
That defeats the purpose of following the tutorial!
Hey i want to tell you that This Eyesight script is literally useless in multiplayer,
The script stops looking to other players if it cant see the first or a player thanks to the “return”,
I would like you to remove the return and add the Check detectibles into them
Hi,
Do you have a .rbxl file with a fix for the issue you mentioned?
Thanks