# Target prediction for nonlinear motion

This topic is 3126 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I'm trying to solve the following problem, and I've run up against a gigantic wall.

You are given:
- Position and orientation of Objects A and B
- Speed of Object A
- Speed of a projectile
- The Yaw, Pitch, and Roll of Object A (note: this is not the instantaneous orientation, these values describe the motion of Object A, so every frame, you apply the Yaw Pitch and Roll to Object A and move it forward by its speed)

The question is: where do you aim so that a projectile fired from Object B will hit Object A?

If the motion is linear, I found this solution thanks to alvaro, which works great, but completely falls apart as soon as the motion is nonlinear.

Any ideas?

Thanks!

##### Share on other sites
An object with a constant angular velocity traces out a circle. You can use the parametric equation of a circle instead of the parametric equation of a line, and do things pretty much the same from there.

##### Share on other sites
I think Sneftel is correct.

You are trying to find the time at which the projectile will hit the target, which means solving this equation:

how_long_it_will_take_bullet_to_reach(future_position_of_target_at_time(t)) - t = 0

At t=0 the expression on the left is positive and, if the bullet is faster than the target, the expression will eventually become negative. You can use binary search or Newton-Raphson to find a solution of the equation numerically.

##### Share on other sites
Thanks, guys! I'll try to work out the math from here.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634111
• Total Posts
3015574
×