Trying to make my AI hit people. So I need a formula to know the time until my projectile will hit the target and also the direction the projectile should be shot at.
Here is an example scenario.
- The projectile shoots from the origin $(0,0)$
- Both projectile and target will move in a straight line.
- Speed of projectile: $v = 2000$ m/s
- Speed of target: $u = 450$ m/s
- Initial position of target: $x = 6000$ m, $y = 0$ m
- Direction target moves: $b$ (above $+x$ axis). $b = 135^\circ$
- Time projectile reaches target: $t$
- Angle of projectile: $a$
Here are 2 equations made from the data.
- $(v \cos a)t = x + (u \cos b)t$
- $(v \sin a)t = y + (u \sin b)t$
How do I get the $t$ and $a$, but mostly I just need the $t$?