Search This Blog

Saturday, September 6, 2014

Predictive Aiming

AI is never finished...only abandoned..

For testing reasons I have made a red circle visible where the enemy thinks you are going to be when his bullet might hit you.  This way it can lead you.   I know there is  "turret" object that has built in aiming but I did this myself with math. 

It basically takes its distance from you and your direction and speed times a constant and predicts your future X and future Y.

To be more accurate at different distances, I took that FutureX and FutureY and ran it through again to get a new distance which will be closer to the actual distance where you're going to end up and did the equation again to get a new more accurate Future X and Future Y.

Really this is a poor man's calculus.  I'm using basic algebra, but I should be getting the integral of the first equation instead of running it twice.  But I'm not quite that math smart... and it works pretty darn good right now!

Before the predictive aiming, he couldn't hit you at all if you were moving any way except toward or away from him... now he hits you most of the time.  He's a big meany head! 

What I'd like to do is a more human-like approach with turrets.  Instead of trying to predict where you're going to be I want them to use trial and error.  They shoot the first time at where you *are... then look at which way they missed and just turn a little in that direction and keep shooting till they hit.

Like the old 1979 Battlestar Galactica turrets shooting at cylons...

No comments:

Post a Comment