Skip to main content
added 825 characters in body
Source Link
VaTTeRGeR
  • 786
  • 5
  • 17

You can't reliably create a full path that you can actually follow through completely to your destination since the ships interaction with the world is very unpredictable (physics-simulation is costly to predict and player input mixes everything up anyway).


You need to check for obstacles in the flight path of the ship, you basically pre-calculate the future positions of the asteroids and of your ship and do a collision check on these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much.

Now when you predict a collision you can try obstacle-avoidance (steering) and/or recalculating the path.


Path-finding is good to get an route that is valid at that point in time but it can be unstable, something changes and BOOM your path changed entirelygoes the other way around, your ship has to stop and/or turn etc, that's where steering comes in, you can solve these almost-collisions with obstacle-avoidance without generating a new path or even generating a path in the first place.

If you rely on path-finding you will need to periodically regenerate the path since in your case a previously valid path isn't guaranteed to stay valid for long when everything moves around. This isn't anything new, other games have to do this too but asteroids is a special case since the whole environment changes continuously.

You need something more dynamic and faster, that's where steering behaviors, like obstacle avoidance, are useful. You can use them stand-alone or in conjunction with path-finding to smooth out the generated path.


Let's say you want to implement obstacle avoidance, first you need to detect and select the obstacles you want to navigate around.

You need to check for them in the flight path of the ship, by basically pre-calculating the future positions of the asteroids and your ship and doing a collision check on all of these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much, but an approximation is often enough.

Now when you have predicted a collision you can change your direction accordingly, there are lot's of algorithms out there that you can borrow from, it's up to you.


That's why iI recommend that you should concentrateto read up on obstacle avoidance instead ofand keep path-finding for later. You will be able to handle many situations by just moving towards your goal and avoiding obstacles on the way there.

Check this out: Moving around/avoiding obstacles


If you want to use for example A* for pathfinding you could take into account the clearance of the space you want to move through to select paths with less chance of a collision.

Clearance-based Pathfinding

Depending on your requirements vanilla A* might be more than enough.

You can't reliably create a full path to your destination since the ships interaction with the world is very unpredictable (physics-simulation is costly to predict and player input mixes everything up anyway).


You need to check for obstacles in the flight path of the ship, you basically pre-calculate the future positions of the asteroids and of your ship and do a collision check on these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much.

Now when you predict a collision you can try obstacle-avoidance (steering) and/or recalculating the path.


Path-finding is good to get an route at that point in time but it can be unstable, something changes and BOOM your path changed entirely, your ship has to stop and turn etc, that's where steering comes in, you can solve these almost-collisions with obstacle-avoidance without generating a new path or even generating a path in the first place.

If you rely on path-finding you will need to periodically regenerate the path since in your case a previously valid path isn't guaranteed to stay valid for long when everything moves around.


That's why i recommend that you should concentrate on obstacle avoidance instead of path-finding. You will be able to handle many situations by just moving towards your goal and avoiding obstacles on the way there.

Check this out: Moving around/avoiding obstacles

You can't reliably create a full path that you can actually follow through completely to your destination since the ships interaction with the world is very unpredictable (physics-simulation is costly to predict and player input mixes everything up anyway).


Path-finding is good to get an route that is valid at that point in time but it can be unstable, something changes and BOOM your path goes the other way around, your ship has to stop and/or turn.

If you rely on path-finding you will need to periodically regenerate the path since in your case a previously valid path isn't guaranteed to stay valid for long when everything moves around. This isn't anything new, other games have to do this too but asteroids is a special case since the whole environment changes continuously.

You need something more dynamic and faster, that's where steering behaviors, like obstacle avoidance, are useful. You can use them stand-alone or in conjunction with path-finding to smooth out the generated path.


Let's say you want to implement obstacle avoidance, first you need to detect and select the obstacles you want to navigate around.

You need to check for them in the flight path of the ship, by basically pre-calculating the future positions of the asteroids and your ship and doing a collision check on all of these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much, but an approximation is often enough.

Now when you have predicted a collision you can change your direction accordingly, there are lot's of algorithms out there that you can borrow from, it's up to you.


I recommend you to read up on obstacle avoidance and keep path-finding for later. You will be able to handle many situations by just moving towards your goal and avoiding obstacles on the way there.

Moving around/avoiding obstacles


If you want to use for example A* for pathfinding you could take into account the clearance of the space you want to move through to select paths with less chance of a collision.

Clearance-based Pathfinding

Depending on your requirements vanilla A* might be more than enough.

added 4 characters in body
Source Link
VaTTeRGeR
  • 786
  • 5
  • 17

You can't reliably create a full path to your destination since the ships interaction with the world is very unpredictable (physics-simulation is costly to predict and player input mixes everything up anyway).


You need to check for obstacles in the flight path of the ship, you basically pre-calculate the future positions of the asteroids and of your ship and do a collision check on these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much.

Now when you predict a collision you can try obstacle-avoidance (steering) and/or recalculating the path.


Path-finding is good to get an route at that point in time but it can be unstable, something changes and BOOM your path changed entirely, your ship has to stop and turn etc, that's where steering comes in, you can solve these almost-collisions with obstacle-avoidance without generating a new path or even generating a path in the first place.

If you rely on path-finding you will need to periodically regenerate the path though since in your case a previously valid path isn't guaranteed to stay valid for long when everything moves around.


That's why i recommend that maybe you should concentrate on obstacle avoidance instead of path-finding. You will be able to handle many situations by just moving towards your goal and avoiding obstacles on the way there.

Check this out: Moving around/avoiding obstacles

You can't reliably create a full path to your destination since the ships interaction with the world is very unpredictable (physics-simulation is costly to predict and player input mixes everything up anyway).


You need to check for obstacles in the flight path of the ship, you basically pre-calculate the future positions of the asteroids and of your ship and do a collision check on these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much.

Now when you predict a collision you can try obstacle-avoidance (steering) and/or recalculating the path.


Path-finding is good to get an route at that point in time but it can be unstable, something changes and BOOM your path changed entirely, your ship has to stop and turn etc, that's where steering comes in, you can solve these almost-collisions with obstacle-avoidance without generating a new path or even generating a path in the first place.

If you rely on path-finding you will need to periodically regenerate the path though since in your case a previously valid path isn't guaranteed to stay valid for long when everything moves around.


That's why i recommend that maybe you should concentrate on obstacle avoidance instead of path-finding. You will be able to handle many situations by just moving towards your goal and avoiding obstacles.

Check this out: Moving around/avoiding obstacles

You can't reliably create a full path to your destination since the ships interaction with the world is very unpredictable (physics-simulation is costly to predict and player input mixes everything up anyway).


You need to check for obstacles in the flight path of the ship, you basically pre-calculate the future positions of the asteroids and of your ship and do a collision check on these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much.

Now when you predict a collision you can try obstacle-avoidance (steering) and/or recalculating the path.


Path-finding is good to get an route at that point in time but it can be unstable, something changes and BOOM your path changed entirely, your ship has to stop and turn etc, that's where steering comes in, you can solve these almost-collisions with obstacle-avoidance without generating a new path or even generating a path in the first place.

If you rely on path-finding you will need to periodically regenerate the path since in your case a previously valid path isn't guaranteed to stay valid for long when everything moves around.


That's why i recommend that you should concentrate on obstacle avoidance instead of path-finding. You will be able to handle many situations by just moving towards your goal and avoiding obstacles on the way there.

Check this out: Moving around/avoiding obstacles

Source Link
VaTTeRGeR
  • 786
  • 5
  • 17

You can't reliably create a full path to your destination since the ships interaction with the world is very unpredictable (physics-simulation is costly to predict and player input mixes everything up anyway).


You need to check for obstacles in the flight path of the ship, you basically pre-calculate the future positions of the asteroids and of your ship and do a collision check on these extrapolated positions. This is easy for asteroids that simply move in one direction with constant speed, for the others not so much.

Now when you predict a collision you can try obstacle-avoidance (steering) and/or recalculating the path.


Path-finding is good to get an route at that point in time but it can be unstable, something changes and BOOM your path changed entirely, your ship has to stop and turn etc, that's where steering comes in, you can solve these almost-collisions with obstacle-avoidance without generating a new path or even generating a path in the first place.

If you rely on path-finding you will need to periodically regenerate the path though since in your case a previously valid path isn't guaranteed to stay valid for long when everything moves around.


That's why i recommend that maybe you should concentrate on obstacle avoidance instead of path-finding. You will be able to handle many situations by just moving towards your goal and avoiding obstacles.

Check this out: Moving around/avoiding obstacles