Hey guys, this week I’ve wrapped up another set of steering behaviors. This time I’ve got a live demo with the different behaviors and some source code to share with you. At this point I’ve probably got enough to turn back to Null Op and start implementing these things in-game. That said I wasn’t able to find a satisfying abstraction to cover every steering behavior; the demo and some thoughts about steering after the fold.
So, what are you seeing here? The flocking behavior is a combination of three different types of steering behaviors. You can see each individually by clicking on the flash canvas and then pressing left or right to change the test case. By themselves each steering behavior is somewhat boring and useless but by layering them together you can achieve lifelike movement between objects!
As I was writing these behaviors I was trying to find an abstraction to consolidate them. In the end I found the following interface worked to capture the three steering behaviors involved for flocking:
/* Steer the subject relative to a set of target vehicles. */
Point steer(Vehicle subject, Vehicle ... targets)
However I have doubts about this interface for future behaviors. For starters there are technically a second class of steering behaviors which really operate under a slightly different signature:
/* Steer the subject relative to a set of target points. */
Point steer(Vehicle subject, Point ... targets)
So far this class of behavior seems to be lower level meaning it might be possible to hide it as part of the subsystem — but it’s certainly a smell.
A second problem I foresee is more complex behaviors. For instance, take obstacle avoidance or pursuit. In these cases the algorithm needs additional information about the environment or where to steer, respectively, which may break the original interface.
In addition, there’s the problem of configuration. The above interface doesn’t address the issue at all but it’s critical. Steering behaviors have a number of parameters which require a lot of tweaking in order to get the “right” result, at the moment I’m not sure what to do about this except to let each implementation of the Steering interface handle configuration itself.
So with all of that said I think it’s time to switch gears and go back to actual game making. Hopefully as I continue to work on Null Op and implement these steering behaviors in context I’ll be able to find some patterns. I hope you enjoyed the demo and feel free to download the code and project associated with it below. As always let me know what you think or if you have any ideas on how to approach this interesting problem!
Hello, my name is Alex Schearer. I grew up in New York and currently live in Seattle.
2 Comments
Hello Can you create an archive for your blog where all posts are listed?
It is hard to look through all your posts for me.
Thank you!
Sure, there are currently archives listed by date on the left hand side and “featured” articles on the right hand side, but I’ll look into creating a better solution which is easier to browse. Good idea!