Hey guys,
I'm currently trying to work out and plan the AI im going to use in my space combat game (3D) but im kinda stuck on a couple of things and was wondering if I could have some help with ideas. Been looking at games like X3 for inspiration.
Currently for the movement of the AI I am using steering behaviours (either directly or I will use them to compute the velocity I need and then turn the ship to face that direction). I will be using a state machine though I might try and use a behaviour tree instead later for its advantages.
The logic for my fighter AI currently is as follows
- in the state machine I will have 3 main states. search for target, attack/chase and flee
- find an enemy ship and set that as a target (will have to make sure not all ships target one enemy but should be easy enough) and move to its location
- once it gets close enough match its speed
- fire if the angle between its forward vector and the enemy's ship is low enough
- start to feel if the my health is to low
- scan for the closest bullet and see if it is heading in the ships direction, if it is use the evade steering behaviour to try and avoid it (this is passive behaviour that will happen in every state)
- another passive behaviour will be obstacle avoidance (avoiding ships and asteroids)
So for this I realised I will have some problems
- The first being that if two ships target each other, they are going to be seeking each other which will end badly
- When i make a ship flee (if i still want to after thinking it all), how would i make it harder to hit. I could give it a random force to push it side to side but using evade or flee from its enemy alone wont work as fare as i know (flee will just move away from it and since the other ship is just heading straight towards the fleeing ship, evade will do the same as flee).
in future I would like to look into fuzzy logic and utility systems with behaviour trees to create a much more intelligent AI but for now I'm just trying to get something that works to an ok extend (game still needs to be fun for the player).
Any ideas or help with understanding concepts/the solution to my problems would be very appreciated. Also open to new ideas of how to do the movement :)