Jump to content
  • Advertisement
Sign in to follow this  
schattenmaennlein

aim at moving target algorithm

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am currently finetuning a 2d topdown shooter and want to implent that the ki can aim at the expected future position of a moving target. Which is a really cool thing to have btw(Im using a dirty approximation at the moment). Unfortunately I havent been able to find an exact formula so far. We know that shot and target will meet if the shot is set off at the right angle. We know the startposition of our shot. We know the speed of our shot. We know the actual position of the target. We know the angle/direction(up is zero) in which the target is moving. We know the speed at which the target is moving. All speeds and angles are constant. And we want to know the angle in which we have to shoot to hit. Or the point the target and shot will meet if we shoot at the right angle. Help appreciated. My thoughts so far (if anyone cares): Using linear functions (y = xm + n) I could calculate the number_of_frames it takes for the two objects to hit if the shot was done at the right angle. number_of_frames = n/(m_two - m_one); The rest would be easy. But I would have to know the speed at which the distance between the two objects is shrinking which I think I cant without knowing the angle at which we would have to shoot. So my idea is probably useless. Thank you

Share this post


Link to post
Share on other sites
Advertisement
This has been covered quite a few times in this particular forum. Try searching the forum archives for 'lead target', 'moving target', and maybe other similar phrases, and you should find some good explanations of the algorithm (and maybe even some sample code).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!