How to use physics sim. to help pathfinding get around walls
Posted: Thu Nov 05, 2009 5:37 am
I'm working on a FPS game, and I've gotten a lot of the basics down. I have very rudimentary pathfinding for the enemies done. My game uses the A* algorithm to determine the path that the enemies take to get from their position to the player's position, and then I create two Curves that define the path to get there. At each update, the enemy moves a small amount along that Curve, which determines it's new position. Right now I'm manually doing checks to see if the enemies (and the player) intersect with the walls, and if they do, I don't move them. This makes the enemies stop in their tracks if they touch a wall.
The problem I'm trying to use BEPU to solve is how to make the enemies move along the wall until they can continue. Here's a picture to illustrate what I mean.
This is what I currently have:

The red line is the enemy's path from A to B, and when it hits the blue wall, it just stops now. The path itself doesn't intersect with the wall, but it comes close enough that the bounding box of the enemy does intersect.
This is what I want:

When the path hits the wall, the physics engine should move it along the wall until it no longer collides.
Because I'm calculating the path the enemy should take myself, I'm not applying forces or setting velocities, I'm simply changing it's position. How can I take advantage of the collision detection and correction in BEPU to do what I illustrated without modifying my code to use velocities to move the enemy?
So far I know that I should add the triangles that make up the walls and probably the ground to a Static Group, and create a Box for the enemy, but I don't know how to make them interact without setting velocities and applying forces.
If something doesn't make sense, let me know and I'll try to explain it further. Thanks!
The problem I'm trying to use BEPU to solve is how to make the enemies move along the wall until they can continue. Here's a picture to illustrate what I mean.
This is what I currently have:

The red line is the enemy's path from A to B, and when it hits the blue wall, it just stops now. The path itself doesn't intersect with the wall, but it comes close enough that the bounding box of the enemy does intersect.
This is what I want:

When the path hits the wall, the physics engine should move it along the wall until it no longer collides.
Because I'm calculating the path the enemy should take myself, I'm not applying forces or setting velocities, I'm simply changing it's position. How can I take advantage of the collision detection and correction in BEPU to do what I illustrated without modifying my code to use velocities to move the enemy?
So far I know that I should add the triangles that make up the walls and probably the ground to a Static Group, and create a Box for the enemy, but I don't know how to make them interact without setting velocities and applying forces.
If something doesn't make sense, let me know and I'll try to explain it further. Thanks!