AI View Field

Sem título.png

With this i can tell to my AI to Follow the player who Overlap the field.
But if i hide behind a wall or something, the AI still Find me. How i block the view field ? To make me hide.

You could try using a line or possible sphere trace to the player. You may have to make sure your view field meshes does not interfere with the trace by either making sure it does not have collision or by making it use a channel other than what you are tracing against (if you need it for some collision purpose).

Nice. I used MultiBoxTraceFor Objects, And works great. But, is there a way to make a Cone Shape ?

You could use a multi box and then check the cone angle of each of your hits.

You would check the tangent of each hit by transforming it into the local box space and checking the cone by comparing the distance from the forward axis (opposite) and the length along the forward axis (adjacent). Since tangent = opposite / adjacent, by dividing those two you can reject hits based on a threshold that is calculated as tan(angle). Doing the tan in the precaulation phase (like in construction script) will make the resulting math much faster since you won’t be doing any trig, only a few dot products, additions and division.

ie for a 45 degree FOV cone you would use the half angle (in order to get 2 right triangles out of it) which is 22.5. The tangent of 22.5 is 0.414 so you would get the distance from the player along the cone axis (adjacent, could be solved as the length of the Z channel after transforming into the local box space) and the distance from the X axis (opposite, which could be solved as the length of the 2d XY vector by multiplying by 1,1,0 after transforming into the local box space). Then do opposite/adjacent and if its less than 0.414, the hit will be within a 45 degree FOV cone (or 22.5 degree half angle).

btw when I say ‘local box space’ I mean a space where the forward vector becomes the Z because it makes the other math a bit easier but you could solve it however you want.

Depending on how many objects are in the scene that you’re looking for, a mathematical cone & distance check might even be faster than any collision shapes at all :slight_smile:

You’d be surprised at how fast iterating an array of objects can be!

soooooo… can you provide a picture of how that would look in blueprints? :slight_smile: