I'm working on this AI and want to be able to directly control what it reacts to. To do this I want to scan its sight on a separate AI map and save any of the parts that is in that area.
This is what I came up with, it shoots some sort of ray or projectile at an angle from the NPC's head and saves whatever it hits into an object value. Then adjusts the angle and does it again.
tempbrain is a configurations folder, infocell is an object value, FOVX is the field of view on the X axis and FOVY is the field of view on the Y axis and samples is a value chosen by me to modify how detailed the scan is.
local raydegreeX = (FOVX / 2) * samples
local raydegreeY = (FOVY / 2) * samples
for i=1,samples*(FOVX*FOVY) do
-- <INSERT PROJECTILE SCRIPT HERE> --
local value = infocell:clone()
value.parent = tempbrain
value.name = viewing
value.value = hit
raydegreeX = raydegreeX - 1
if raydegreeX = (FOVX * samples) * (-1) then
raydegreeY = raydegreeY - 1
raydegreeX = (FOVX / 2) * samples
end
end
The problem I have is figuring out how to do the projectile part. There is probably an easier way to do this as well so that could be helpful too.
I went with using rays.
