Sensing when near a wall?

edited April 2013 in Help request
Just a quick question:

I've implemented a boids algorithm for simulating the motion of schools of fish. Rather than the fish dumbly smacking into the walls of the map, I'd rather they begin turning before hitting the wall.

I was thinking maybe having a sensor (a non-solid wall) "zone" near the walls that the fish class could use as a hint to "turn around", maybe include a meta-data vector that "pushes" them away from the wall?

Would this be the "right way" to do this or am I doing it the hard way?

--Eric

Comments

  • edited April 2013
    If it were me, I'd probably go with the sensor option.

    Unless the zones to avoid are hard to represent with "hard walls" and need to be less binary, in which case using some kind of distance fields could do the trick.

    Lastly, you can also issue raycasts to test proximity of physics bodies.

    Did you use Craig Raynold's work on boids (http://www.red3d.com/cwr/boids/) btw? He also has nice interesting steering tutorials on his site that I used a long long time ago. :)
  • edited April 2013
    Of course, I'd seen Reynold's site, but I hadn't seen the obstacle avoidance yet. Thanks!
Sign In or Register to comment.