I’m having trouble with zombies detecting players within its field of view while limiting the Y-Axis radius (so they can pathfind up to the top or other floors above the players without the zombie detecting the player on the room and go straight towards its direction thus slamming onto the wall).
What I mean by limited the Y-Axis radius, is limiting how far the ray can detect on the Y-Axis (ex. 5 studs)
local Hit, Position = workspace:FindPartOnRayWithIgnoreList(Ray.new(self.Torso.Position, self.Target.Position - self.Torso.Position), Ignorelist)
if Hit ~= nil then
print(Hit)
if Hit == self.Target or Hit:IsDescendantOf(self.Target.Parent) then
print( "icu yo ;)" )
self.TargetIsInView = true
end
if not Hit.CanCollide or Hit.Transparency > 0.5 then
Ignorelist[#Ignorelist+1] = Hit
end
end