How to make raycast cover cone area?

Making my game, the enemy NPCs just run after players when they get within a radius of them. But I want them to have a sort of vision so that they run after players in their vision. Since I’m new to raycasts, is there any way to make this “vision” spread in a cone formation or make raycasts thicker?

Raycasts have infinitely small width. Just spam tons of them out. I’d use a spiral like the fibonacci sphere to try to evenly distribute raycasts out.

How would I do this? The code is in python and I have no idea about raycasting except for where it comes from and the direction.

Might be better to just manually check the angle between the characters and the NPC’s then.

A Dot product check can be used to get an angle to compare against the cone.

3 Likes