Requesting math help : Aim leading


I’m trying to set up a turret that tracks a pawn and fires at it. It is easy for me to create a turret that fires and hits a stationary actor (using the find look at rotation node), but I don’t know the math involved in making this turret account for the target actor’s speed. (I’m not concerned with acceleration/deceleration)

I know it will involve the start and target locations, the projectile speed, and the target actor speed, but I don’t know what math to preform to make this calculation.

I would need to find the angle to lead the turret’s firing in 3D space, not just 2D.

Some math guru… please help!


I wouldn’t get too carried away with the math if you can cheat. Instead of doing all the calculations to predict where something should be I would first try to use what is called a forward vector. Basically, it’s the direction an object is pointing(or moving). In a first person shooter example the forward vector is where your bullet is going to go. You could get the forward vector in blue prints with “get forward vector” to know which direction the pawn is heading the moment the turret fires. You can then multiply that forward vector by a constant to increase the size(how much the turret will lead the target when it fires).

4music2junkie0 did this tutorials (like 4 parts) on that subject which will may help you :
in hope it helps you.

Hi sanford87, thanks for the tip! I’ll try out the get forward vector approach in blueprint.

Hi Fen, I’ve seen that tutorial however It unfortunately does not account for the movement of a target, so it would always miss a target in motion. Thanks for the link anyway though!

Perhaps when I figure this out I should make a tutorial myself.

So the idea would be tick a : get x1y1z1 pawn (like get player pawn absolute position). tick b : get x2y2z2 pawn calculate x3y3z3 (which would be like x2+(x2 - x1), y2+(y2 - y1),z2+(z2 - z1) if x2,y2,z2 is the central point of calculation (0,0,0).

and tick 3 : shoot there (x3y3z3), no ? (That in absolute position (which can be considerating like cheat but is not because only players cheat not devs :p)

To read it again it looks like the forward vector said upon it seems but do with basic stuff ^^

So using relative position to detect and absolute to know positions…

I have edited to change a bit the math from yesterday night to this morning if someone concerned seen this post before now ^^.

Even though I agree with sanford87, you should get the velocity vector instead of the forward vector, to account for strafing and falling.

So if you add the velocity vector to the targets current position, then you get the position that the target is in a second from now. So you just have to aim at the position the target will be instead of his current position.

Dont forget to incooperate some kidn of inaccuracy within this system, otherwise it wouldnt feel natural if all your shots land perfectly.