I'm trying to make a sniper aim prediction for an Unreal Engine 4 game. I've found this interesting question Projectile Aim Prediction with Acceleration, and I tried to implement in C++ what DMGregory said. The result I got isn't bad at all, but I've some doubts about something in his explanation. First, what does he mean with v_T? Should I calculate it as FVector v_T = targetVelocity - myVelocity;
or as
FVector v_T = targetVelocity - myPosition;?
The vectors myVelocity and myPosition are respectively the velocity and the position of the shooter (me).
Then, I noticed that the sniper projectile trajectory doesn't seem to be a perfect parabola, so I avoided the v_p calculation, and I've simply calculated the predicted target position as
FVector predictedTargetPosition = targetPosition + targetVelocity * deltaTime + targetAcceleration * deltaTime * deltaTime * .5f; where the 3 vectors targetPosition, targetVelocity and targetAcceleration are relative to the game world axis.
After that, I simply added to the Z component of the predictedTargetPosition the following amount:
recalculatedTargetPosition.Z += fabs(bulletAcceleration.Z) * deltaTime * deltaTime * .5f; in order to compensate the loss of height of the projectile in time.
What do you think about it?
Thanks in advance.