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

Suggestions for fixing boid example? #5

Closed miketucker closed 12 years ago

miketucker commented 12 years ago

hey Ricardo,

I think the radar changes (http://www.arges-systems.com/articles/252/unitysteer-experimental-vehicle-and-radar-changes/) threw something out of whack and now the boids jitter around randomly.

I've spent the afternoon tweaking but haven't had much luck.. Any suggestions?

best, mike

ricardojmendez commented 12 years ago

Hi Mike,

Actually, this is likely because of how AutonomousVehicle currently interprets the forward vector (which is mentioned on the same article). If you attempt to run the boid example, they'll look as if they're having a seizure. I'll need to figure out what to do with that - it's possible that I may end up keeping AutonomousVehicle the way it was and fork the current behavior into a different class.

For now, if you're running into one of those cases, you may need to stick with the master branch.

ricardojmendez commented 12 years ago

Let me elaborate a bit more on what the issue is here, from the point of view of how things are on master. It's not just an issue of tweaking - this stems from the completely different way in which the development / master versions perceive velocity.

For master (and the working boids) velocity is an effect of its forward vector and speed. When it decides to move,it moves forward and can change direction by gradually moving its forward vector to be aligned with the new desired velocity. This means that they'll tend to move forward before turning around, like a car or a bird in flight would do.

For development (and the dubstep-dancing boids) velocity is the actual movement we're executing. Instead of tending to move forward, the agents are able to move in a direction while retaining a different forward vector. The jittery that you're seeing is the effect of the boids not gliding, but instead trying to sides-step each other. The new behavior just doesn't lend itself for boids.

If you want to retain the more vehicle-like behavior but take advantage of other improvements from the development branch, you could look into merging both AutonomousVehicle classes, or reverting the relevant commit, although I doubt such a change would apply cleanly:

https://github.com/ricardojmendez/UnitySteer/commit/65d15d9dfe65436c2e56c876c2a38750b96e9da6

That commit also explains the changes, so it might be good reading if you're considering adjusting the code.

miketucker commented 12 years ago

hey Ricardo,

Thanks so much for your time. I've worked through it at this point. A while back i wrote you because the master branch wouldn't compile on iOS so i switched to the dev branch. It compiled but broke the boids :)

So today after writing you, I took the master branch, removed the C5 dependency and that fixed the iOS compile. Really amazing job on this library, hope I can return the favor sometime. Btw I've been keeping an eye on your tile-based game, looking forward to playing that.