Get Projectile init direction by hit location

Hello guys!

I have some Math stuff here. What I need, is get projectile spawn rotation by some information I do have.

G - Gravity vector
Vh - Hit location coords
S - Initial speed

So… At first I was using next formula to get hit location:


Vh = Vi * T + T^2/2 * G

Vi - Initial velocity
T - time from begining

Geting initial velocity by end hit location was pretty easy here:


Vi = (Vh - T^2/2 * G)/T

It works, but here I have dynamic velocity and I must know existing time of a projectile before hit.

But what I need, is static velocity length (speed) and automatic time calculation (or get rid of that).


Vh = Vi * S * T + T^2/2 * G

Vi = (Vh - T^2/2 * G)/(T*S)


But here I still have to know the time of reaching target.

Can anyone help me finding T here (I’m not sure I’m able to get a formula of T)?
Or giving me another formula or another way to calculate all the stuff from G, S and Vh?

I would be very thankfull…

Can you make a timestamp on the projectile when it was launched/spawned and determine the time of it’s existance when it hits something?

I must calculate all the stuff before spawning. And in order to spawn, I must calculate initial launch vector first (spawn rotation in our case).

So what you are calculating is the parabolic trajectory of a projectile?

Edit: maybe this will help Projectile motion - Wikipedia

http://www.n-created.com/2013/11/12/projectile-initial-velocity-angle-to-hit-coordinate/

I don’t know you want exactly hit time for what purpose. But I check it hit or overlapped by some invisible stuff pre projectile before I launcher the visible then. There are other way but it not corrected right way to calculate. That you use interpolate the origin direction to the tick time direction from your projectile to destination location or actor it working like a heat tracing rocket.