Background
I'm building a simple game where two ships are launching missiles at each other in space.
Stuff got complicated when the ships started moving in a frictionless environment and the missiles naturally needed to do the same thing.
Premises
- A missile has a constant acceleration and is trying to hit a moving target in a frictionless environment.
- Target is also constantly accelerating in the same frictionless environment.
- The frictionless environment is only 2 dimensional
- There is no gravitation affecting the missile
Question
What math should I use to determine the direction the missile should jolt in?
What i have right now
I've implemented this answer which works quite alright. I am not 100% sure of what a, b, c etc means and not sure which math is actually implemented here.
I modified above linked answer by making the missile mimmic its targets jolts and adding its own on top of those. It is an ugly solution to say the least.
Problem with current solution
The current solution requires to know the speed of the missile.
The missile is constantly accelerating, and it has no top speed.
Unless I know how far the missile will travel, I cannot know the average speed.
Above solution requires that I know the speed of the projectile.
x = xstart + vstart*t + 0.5*a*(t^2)
let you calculate thex
position given a starting positionxstart
, a starting speedvstart
, and the accelerationa
, while timet
is the variable you increment to compute the formula. – liggiorgio Jun 03 '16 at 14:44