Hello. Im working on a game that your mission is to steal as most items you could and there is also guards so now my question is, How to make an NPC view area so if the player went on the guard view area the guard will try to shoot the player but there are a few problems I tried to use magnitude but that would detect players through walls then I welded a part to the guard but the part could go through walls is there any solution?
Yes and NOT through walls so after that guard will start to shoot the player
So what I am understanding is that you want the NPC to only see the player when they are in a specific line of sight?
Yes as i said in front of the guard and not through walls
How about you just use raycasting?
Well im not sure how to use it
I know I am using a deprecated method of raycsting but
something like this is what you would want to do
local ray = Ray.new(origin,direction)
local hit,position = workspace:FindFirstPartOnRayWithIgnoreList(ray,{character})
if hit then
if hit.Name == workspace.Wall.Name then
print("blah blah")
end
end
Sorry I know its really sloppy but like thats just a rough draft kinda thing
Thanks its working! but i added a invisible part in front of the npc a few studs away but when the npc move the npc would kinda dash(i dont know you understand or not sorry)
Yeah I get what you mean, make the part canCollide off and make it massless in properties