ricardojmendez / UnitySteer

Steering, obstacle avoidance and path following behaviors for the Unity Game Engine
https://numergent.com/tags/unitysteer/
Other
1.21k stars 276 forks source link

Cohesion Behavior doesn't take position of boid being steered into account? #6

Closed MichaelDCMack closed 12 years ago

MichaelDCMack commented 12 years ago

Hi!

First thing I tried after opening the boids example was reducing it to two birds who only had Cohesion Behaviors. I then made the Cohesion Behaviors aware of everything within 180 degrees and radius of 20.

Strangely, the birds consistently behaved badly. One would head for the edge of the screen and the other would follow (based on the initial positions).

So I looked, and when the center of the boid 'flock' is found in the Cohesion Behavior, it is found in global space rather than 'current boid relative space'. That means that the forces being generated were only proper if the current boid being steered happened to be at the origin.

When I fixed this, the boids continually 'seeked' each other as I was expecting.

Bug or feature?

ricardojmendez commented 12 years ago

Hi Michael,

Not sure why this issue escaped me, but you seem to be right - that would be a bug. Thanks!

ricardojmendez commented 12 years ago

Resolved on commit a47da05