Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

I am attempting to implement a boids flocking model in unity.

I have managed to implement steering behaviors (separate, align, cohere) but I am currently using a fixed radius from the agent to define its neighborhood (essentially a bubble around the agent). However, what I need to implement is a vision cone like the one detailed in this image:

boids vision cone

I'm unsure how I could implement this in unity. Could someone point me in the correct direction?

To add clarity, what I want to do is detect all other agents in a vision cone, but I'm unsure how to implement it. Currently, I am just detecting all agents within a distance, though I need to ignore the agents behind the one doing detecting ( like in the picture) I'm not looking to visualize it, just detect the agents in that defined neighborhood.

thanks

1 Answer

0 votes
by (108k points)

First, detect all the agents in the circle, then check for every one of those the Vector3.Angle() between transform.forward and the direction to the agent. (as the direction from vector A to B is just B to A).

Browse Categories

...