PandaSteer 2

Ok, updated again: download.

Added obstacle avoidance steering behaviour and a couple more plugins to demonstrate it. The code is pretty rough at the moment but obstacle avoidance works really well with Panda’s collision system, it’s very fast and robust, I’m pretty happy with it.

I used a Panda CollisionTube, projected ahead of each character, to detect upcoming collisions with obstacles, represented as Panda CollisionSpheres. Since the manual says CollisionTube is good only as an into object I used it as such, and used the static CollisionSpheres as from objects, even though conceptually, the CollisionTube is the thing that’s moving so would seem the logical choice as the from object. When a collision occurs between a character’s CollisionTube and a CollisionSphere, a steering force is applied to steer away from the obstacle.

Some work needs to be done:

  • If the target a character is trying to arrive at (for example) is inside an obstacle the character will run round and round the obstacle

  • Worse, if the target is just in front of an obstacle, the character may arrive at the target and stop, but then the CollisionTube may be colliding with the obstacle, which will cause the character to run around needlessly trying to avoid the obstacle

The best way to fix this I think would be to vary the length of the character’s CollisionTube frame-by-frame according to the character’s speed, so that when the character comes to rest at a target location the CollisionTube will shrink to a sphere around the character and not collide with any obstacles beyond the target. I had trouble implementing this though and have given up for now.

The collision avoidance (that is, avoiding other moving characters, not static obstacles) behaviour could be improved a bit. It does not use pandas collision system to detect upcoming collisions but my own code, and collisions seem to occur fairly often with a lot of characters in a small space. Is it possible to collide two CollisionTubes against eachother? If so, the characters CollisionTubes could be used to detect character-character collisions also.

The ‘follow’ steering behaviour needs improvement. The character needs to follow a good distance behind the target so as not to collide with the target, needs to avoid blocking the path of the target, and needs to avoid bumping into other followers. Ultimately it should be more like the demo here: red3d.com/cwr/steer/LeaderFollow.html

yjnh_jo: thanks a lot for your fix for the cracks in the terrain. It’s definitely going to be crucial for me in the future. I haven’t had time to merge the fix into my own download yet, but will do so as soon as I can.

Thanks, and enjoy! :slight_smile: