pathfinding in 3D
Blitz3D Forums/Blitz3D Programming/pathfinding in 3D
| ||
I have 2 entities, one is chasing the other in 3D space. They are both moving forward at a constant speed and are programmed to turn to face their targets. Problem is, there is a huge cube between them. How would I tell them to go around the cube instead of bumping into it? How would I get them to recognise that there is an object in the way that needs to be navigated? Is there a way to make them align to the normals of the cube? - this would allow more complicated obstacles. How would I get them to realise that there is no need to follow the cube around anymore? |
| ||
pathfinding is a big chapter. depending on the situation there are many diffrent methods. One popular is named A-star. this is a demo source you might find interesting. http://www.melog.ch/dl/astar3D_2.zip and here a recent discussion: http://www.blitzbasic.com/Community/posts.php?topic=31910 |
| ||
thanks |
| ||
Is pathfinding required? A simple way could be by using waypoints: If it is a cube in 3D space - like an asteroid in space you can put in 3d waypoints: ............WP...WP...WP.......... .................................. ...............OBJECT............. ............WP.O.WP.T.WP.......... ...............OBJECT............. .................................. ............WP...WP...WP.......... Basically, like satellites around the world - except they are static - us as many as you like. Your entities will only need to pass through a minimum of 3 waypoints to arrive at the other side of the cube. The routes could be precalculated, but the decision of which route to take does not (unless you want it to be). When arriving at the cube, aim for a waypoint - throw a random number and off it goes (left, right, top or bottom) - knowing which waypoint to head for next in advance. The waypoint will know it's opposite waypoint, thus it will be simple to navigate around - when arriving at the opposite waypoint the entity will know it has navigated around the cube. I hope that makes sense. |