AI for a Space Shooter
by Funky Diver · in Technical Issues · 10/23/2004 (2:05 pm) · 7 replies
Greetings,
As I've noticed people mostly discuss AI for RTS and/or FPS using terrain based approach.
All of those technics are well discussed in many resources, but I cannot find anything good for the Space Shooter genre.
I would like to get some advices for creating AI for the spacecraft pilots. Any help will be appreciated!
What I need to make is:
1) Enemy pilots AI: attack, chase in real 3D (not on terrain), obviously, I cannot use helper markers for the terrain navigation...
2) Teammate AI: chase leader, chase and attack target.
The most difficult I find the movements and chasing for AI, because I cannot use any kind of grid (it would eat too much time and will slow the CPU, I think). I wish I could now how they made AI for X-Wing series space shooters :)
Thank you!
As I've noticed people mostly discuss AI for RTS and/or FPS using terrain based approach.
All of those technics are well discussed in many resources, but I cannot find anything good for the Space Shooter genre.
I would like to get some advices for creating AI for the spacecraft pilots. Any help will be appreciated!
What I need to make is:
1) Enemy pilots AI: attack, chase in real 3D (not on terrain), obviously, I cannot use helper markers for the terrain navigation...
2) Teammate AI: chase leader, chase and attack target.
The most difficult I find the movements and chasing for AI, because I cannot use any kind of grid (it would eat too much time and will slow the CPU, I think). I wish I could now how they made AI for X-Wing series space shooters :)
Thank you!
#2
Now I have a question about how do I calculate the attacking point that comes in front of a target for AI? Is there any tutorial, some formulas?
You are right about collision avoidance, I completely forgot about it! Now, the same question is for calculating temporary way point to avoid a collision...
Thank you again!
10/24/2004 (11:12 am)
Thanks, Michael!Now I have a question about how do I calculate the attacking point that comes in front of a target for AI? Is there any tutorial, some formulas?
You are right about collision avoidance, I completely forgot about it! Now, the same question is for calculating temporary way point to avoid a collision...
Thank you again!
#3
For the simplest case: Get the distance to the target. Find out the time it takes the projectile to travel that distance. Based on the target speed, calculate how far the target would have moved in that time and you have the lead point. There can be a lot more to it than that, but you get the idea.
Using bounding spheres makes things quick and easy for collision avoidance. A ray cast along the target vector is done checking all objects. If a collision is found you can then generate a temporary target point that is offset from the original vector by the radius of the sphere. With just a little more work you could find the closest edge to the collision point and have the temporary point here. This would probably look better and would make the AI seem smarter, especially for larger objects. Another gotcha to watch out for is where the temporary point has a collision on it's path.
10/24/2004 (3:00 pm)
Sorry, I don't have any formulas or links to tutorials for target lead calculations.For the simplest case: Get the distance to the target. Find out the time it takes the projectile to travel that distance. Based on the target speed, calculate how far the target would have moved in that time and you have the lead point. There can be a lot more to it than that, but you get the idea.
Using bounding spheres makes things quick and easy for collision avoidance. A ray cast along the target vector is done checking all objects. If a collision is found you can then generate a temporary target point that is offset from the original vector by the radius of the sphere. With just a little more work you could find the closest edge to the collision point and have the temporary point here. This would probably look better and would make the AI seem smarter, especially for larger objects. Another gotcha to watch out for is where the temporary point has a collision on it's path.
#4
Link to abstract and vid:
http://www.eg.org/EG/DL/WS/SCA/SCA04/009-018.pdf.abstract.pdf;internal&action=paperabstract.action
Paper link:
www.kuffner.org/james/papers/go_sca2004.pdf
Chris
12/15/2004 (3:31 am)
An interesting paper at this years SCA conference discussed real-time path planning and movement behaviours in a space environment with lots of obstacles- may provide ideas, etc.Link to abstract and vid:
http://www.eg.org/EG/DL/WS/SCA/SCA04/009-018.pdf.abstract.pdf;internal&action=paperabstract.action
Paper link:
www.kuffner.org/james/papers/go_sca2004.pdf
Chris
#5
12/15/2004 (11:50 am)
Thanks a lot, Christopher, I will look at them for sure!
#6
- Brett
12/15/2004 (12:03 pm)
Try applying these in 3D. A lot of what you're discussing would involve simple flocking, obstacle avoidance, leader following, and such. You could implement more goal oriented behavior selection, but it's probably a good start.- Brett
#7
Thank you, the idea of flocking is interesting...
12/16/2004 (12:10 am)
Yes, I was already thinking about Steering Behaviors, creating second bound spheres around objects to find how to avoid them, as Michael Day stated (look above).Thank you, the idea of flocking is interesting...
Torque 3D Owner Michael Day
1) All movement is based on a destination point. The destination point can be either a stationary point (ie a beacon) or a mobile point (a ship). For a mobile point, the destination can be updated every think cycle of the AI. Get a vector to the destination point and have the AI pilot turn to match the ship forward vector with the vector to the destination. When chasing, the destination point would be behind the target. When attacking, the point should be in front of the target. The amount to lead the target by would be based on the speed of both ships, the distance and the speed of the projectile. The target lead calculation is a good place to put the AI skill level. The very best AI would have no error in this calcuation whereas a rookie would have a random offset to the expected targeting point.
2) The methods are much the same as for 1). The only difference is that the target is supplied by the leader rather than an AI target selection.
Of course, if you start adding clutter to space it complicates things. You would then have to have a collision avoidance mechanism rather than just 'flying blind'. This could be as simple as having bounding spheres for each object. A temporary destination point is then calculated to avoid the collision.
Simply trying to match the vector to the destination can result in wobbling, where the movement of the AI ship makes the previously calculated vector slightly incorrect. The AI can end up chasing the correct vector as it can never get an exact heading. This can be overcome by ignoring very small differences between the vector to the target and the ship vector. When the difference goes above the threshold value the AI will make a minor course correction.