I am curious how to implement a spaceship attack logic. I have states set up to do checks for each “command” each ship is given, but am unsure how to code logic for attacks.
Some ships will have to “orbit their targets”, such as giant battle cruisers that have guns and armor on the sides, while others attack head on and then turn away to avoid collisions. The one I want to concentrate on is about fighters.
I want the fighters to do an “attack run”, they will circle the target (clockwise or counterclockwise) and then line up a run to go towards the target and shoot missiles and such, and then once they get close enough to veer off and repeat the action (not necessarily from the same angle of attack however).
I am currently using the “Arongranberg a* pathfinding project” for my game movement ai. I want to essentially create a kind of bezier curve that is centered around the target that the attacking ship follows to perform this movement. I also want to take into account of obstacles to left or right when deciding which way to turn when breaking away from the target after an attack run. How would I do this without too much overhead cost in cpu (as my game will eventually go to mobile).
My ideas are to generate two bezier curve paths (one for turning left out of attack run and one for turning right out of attack run) and then just switching to the appropriate path. I also want to accommodate for the ship moving (but i’m sure i can just use waypoint offsets like its parented to the target).
My other problem is to handle going clockwise or counterclockwise.
How would any forum-goers choose to do this, and can you provide an example code showing how to generate this waypoint path and how to modify it and switch between paths
(i’m assuming it would just be an array of vector3 arrays).
PS: I want to avoid using unity’s physics system as i want to maximize the number of agents i have and be careful in consideration for eventually going mobile so i don’t have to change a ton later).
PPS: [The style of attack i want is similar to aircraft fighters or spaceship fighters from Sins of a Solar Empire or Homeworld 2]