Hey guys, I have a game where tank-like robots form teams and battle each other in an arena, think kinda robot wars but with automatic rifles and etc.
(I think that’s enough to go on, please say if you need to hear more)
Incase the title didn’t make it clear, all I’m talking about is how the AI will control this, I don’t want to change the mechanics, I don’t know if this is truely the place for this post, but I don’t have a “how” question, I have a “what” question.
My current dilemma is about the ballistic weapons, or more precisely - other robots that are fired on by them.
my code for aiming the ballistic weapons (mortar & howitzer) takes into account the target velocity, time to target and a few more details to get a better estimate of where to aim to hit the target (and I must say I’m very surprised by how accurate it is given I only do 1 iteration to get each value), ofc the player does this by himself if so he chooses, I only give him a line renderer displaying the predicted path (it has deviation tied to weapon quality).
V this part is not implemented yet and is basically the question V
now, the way to dodge an incoming projectile is obvious if we know it doesn’t take change in velocity - change you velocity. (I’d have to keep track of the change over time and a whole bunch of other shit I ain’t got time for to do that)
we can do that by either:
speeding up - the closer we are to the top speed the less effective this is, my robots doesn’t have any fuel efficiency curve that goes with speed or anything like that, so they are mostly moving at top speed or are accelerating to it unless they are turning
slowing down/reversing - but what if we wanna keep going forward, what if stopping in place isn’t the best idea? some one can see this as a ramming opportunity - might be fun if the player is the one doing the ramming (you can control individual tanks), but I’d consider this “dumb” AI.
turning - turn a little to the left, move out of the hazard zone, turn back right for course correction to keep heading where you want, I dunno, seems like the ideal solution to me, please poke holes in this one at will.
use a special tank-jet pack to hop over the projectile and crush the enemy tank - jk, lol nothing else, if you have another idea please suggest so, there aren’t any more controls really… the turret can technically shoot the projectile mid-air, but that’s a ridiculously tough shot to make unless I “aim bot” the robots, heh.
okay, so the way I’m going to alert the tanks that they are begin fired on by a mortar is by placing “Hazard” object where the projectile is gonna hit, (that is probably just a trigger and maybe a mini script, i dunno it’s not real yet, maybe check distances to avoid the collider overhead, can still do both circles and boxes), it’s gonna work with stuff like pitfalls (actual pits that you fall though), saws, flames, other stuff that are, you know… hazardous.
how should the tanks behave when in a (incoming projectile) hazard zone? just tell it “rotate an arbitrary number of angles in an arbitrary direction” and after the danger has passed just let the normal AI calculations do the course correction?
find the closest “exit point” from the hazard zone, given the current position velocity and heading and go that way?
the way the tanks will react to static hazards the are always there, or atleast for a DOT effect that’s toggling on and off or even the pits that can open and close is just plop the position into the already-implemented (and working) obstacle avoidance with a high weight, maybe I should just use that then?
I should also mention this all takes places in a circular arena with a uniform height.
so… yeah, kinda overcooked my head today on this one, what are your thoughts?
sorry if I’ve left something vital out, I’ve kinda overcooked my brains today, heh