3d implementation of Wall avoidance?
I've been looking for weeks and weeks for an example of the wall avoidance steering behavior in 3d but I've come up empty. OpenSteer does not implement this behavior... Does anyone know of a good example for wall avoidance in a 3d environment using c++ or java? Thanks in advance.
==========================big kid with adult powers==========================
Isn't it just a simple case of IF going to collide with wall THEN steer away from wall (ie. perpendicular to it)?
Quote:
Original post by Kylotan
Isn't it just a simple case of IF going to collide with wall THEN steer away from wall (ie. perpendicular to it)?
I did something similar a while back and it worked great, could navigate through mazes etc and with a few tweaks hardly ever got stuck either.
Best regards, Omid
I guess meant "containment" using feelers and such to detect walls and doorways. But it's not too far off from what you are saying. I understand all the concepts but I just think better in C++ if that makes sense. Plus I'm sort of an 3d game prgrammer novice so example code goes along way for me... But thanks anyway.
==========================big kid with adult powers==========================
Trace with your collision volume to your desired destination
Check for collisions, save plane of collision if any.
if no collision, just move to your destination (exit).
if there is a collision move to the point of collision
project the remainder of the trace to the plane of collision and move there, perhaps checking again for more collisions.
You could use beveling planes so your character doesn't just walk right next to the walls.
Check for collisions, save plane of collision if any.
if no collision, just move to your destination (exit).
if there is a collision move to the point of collision
project the remainder of the trace to the plane of collision and move there, perhaps checking again for more collisions.
You could use beveling planes so your character doesn't just walk right next to the walls.
Do you have a physics engine? If so, it should supply ray casts, which will let you implement the 'feelers'. It should let you know how close you are to a wall, the perpendicular vector: everything you need. In psuedo code:
And you could certainly get fancier. For example, change direction not based on the normal, but based on forwardVector reflected off the wall (that would make it so that the more directly you are hitting the wall, the more sharply you will turn).
float steeringSpeed = SomeConstant; //Determines how fast you turnfloat rayLength = AnotherConstant; //Determines how far from the wall you need to be to turn//Send out a 'feeler'result = CastRay(forwardVector, rayLength);//See if there's something infront of usif(result.hitSomething){ //Modify our current direction so that we don't hit the wall forwardVector += result.normal * steeringSpeed * result.depth;}
And you could certainly get fancier. For example, change direction not based on the normal, but based on forwardVector reflected off the wall (that would make it so that the more directly you are hitting the wall, the more sharply you will turn).
Ty Ezbez
I think that's the trick I need to investigate.
I'm using OgreOde. They have a Ray class and it looks like it has enough for me to figure out the problem.
I think that's the trick I need to investigate.
I'm using OgreOde. They have a Ray class and it looks like it has enough for me to figure out the problem.
==========================big kid with adult powers==========================
Just FYI for anyone that cares, this worked like a charm with OgreOde. I'm probably not using the OgreOde::RayGeometry as documented but it's working well. The collision detection stuff was the part that had me stalled out. All the 2d examples I saw did it from "scratch" for some reason I couldn't translate that to 3d in my head (3d math noob but getting the hang of it I hope)
I'm using 5 RayGeometry's to make my feelers (space fighter ships) when I get a collision I use the "contact" structure passed to me and apply force as described above. The reflected vector is also easy to get with OgreOde so I'm going to try that next. I'm down to just tweaking for best performance.
Thanks ;-)
I'm using 5 RayGeometry's to make my feelers (space fighter ships) when I get a collision I use the "contact" structure passed to me and apply force as described above. The reflected vector is also easy to get with OgreOde so I'm going to try that next. I'm down to just tweaking for best performance.
Thanks ;-)
==========================big kid with adult powers==========================
Are you bound to using a steering behavior? I've always found it easiest just to disable collision with AI and anything but the floor. Then you just A* around the walls. Interpenetration with walls then becomes an aesthetic issue that is solved by either moving walls around or fixing the A* network generation code to give more of a buffer around walls.
Basically, A* nodes are not generated where walls are so the AI will never try to path there.
If you're just using steering behaviors then feelers is the way to go (i.e. bump & steer). However, you will have problems with local concave areas that will need to be dealt with either by logic or by level design.
-me
Basically, A* nodes are not generated where walls are so the AI will never try to path there.
If you're just using steering behaviors then feelers is the way to go (i.e. bump & steer). However, you will have problems with local concave areas that will need to be dealt with either by logic or by level design.
-me
Palidine,
Awesome insight.. Thank you. But my game is a 3d space shooter with 360 degrees of movement. Everything I read about A* was that it is best used when there is a map with grids to define the map.. Please correct me if I'm wrong
The reason why I choose steering behaviors is because we have open space with spherical obstacles (asteroids and space junk) and the occasional tube (asteroids with tunnels and space flight decks). So to my novice analysis concluded that steering behaviors was the way to go...
Thanks for the head up on concave areas... I don't think we have too many of them but I'll be aware when it happens.
Awesome insight.. Thank you. But my game is a 3d space shooter with 360 degrees of movement. Everything I read about A* was that it is best used when there is a map with grids to define the map.. Please correct me if I'm wrong
The reason why I choose steering behaviors is because we have open space with spherical obstacles (asteroids and space junk) and the occasional tube (asteroids with tunnels and space flight decks). So to my novice analysis concluded that steering behaviors was the way to go...
Thanks for the head up on concave areas... I don't think we have too many of them but I'll be aware when it happens.
==========================big kid with adult powers==========================
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement