5

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

I have managed to implement steering behaviours (separate, align, cohere) but I am currently using a fixed radius from the agent to define its neighbourhood (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

Im 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 visualise it, just detect the agents in that defined neighbourhood.

thanks

Chris Headleand
  • 6,003
  • 16
  • 51
  • 69

1 Answers1

2

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.
(the direction from vector A to B is just B-A)

kat0r
  • 949
  • 8
  • 17