Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 623137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:03:36+00:00 2026-05-13T19:03:36+00:00

For a 2D game I’m working on, I’d like to figure out when a

  • 0

For a 2D game I’m working on, I’d like to figure out when a projectile reaches its closest to point to its target.

A projectile is a point that moves by a constant dx,dy per frame.
A target is another point whose speed relative to the projectile is slow enough as to be considered stationary.
I want to have the projectile explode when it is (approximately) as close to the target as it will be.

What’s a good way to calculate this?

Absolute precision is not critical, this is the client-side simulation of an event that has already been resolved on the server. I’d prefer an algorithm that was fast and simple to one that was pixel perfect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:03:36+00:00Added an answer on May 13, 2026 at 7:03 pm

    Keep track of the previous distance, and check for the first moment the distance starts to increase.

    if ((currentDistance==0) || (currentDistance > previousDistance)) Explode()
    

    It is only this simple because you path geometry is trivial (i.e. a straight line), but it works just fine.

    This has the added advantage of working when the target is faster than you describe as well, so long as both tracks are straight (or at least gently curving).

    Limitation, you step size needs to be small compared to the “size” of the explosion, or this won’t work right. In that case, you would need to precompute the next distance…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a game that will allow content development and I'd like it to
A game that I play stores all of its data in a .DAT file.
For a game I'm working on, I wanted to throw the audio on another
Im working on a game, and ive seen a lot of memory consuption, im
In my spelling game there is a grid that is populated with words. The
I'm playing with Game Center and cocos2d because I want to find out how
The game is simple where the Pan object catches the Pizza objects that are
I have written a game in Flash (AS3/Flex SDK/MXMLC) that streams music and sound
game.multiplayer = bundle.getString(multiplayer ,null); is giving the error: java.lang.NoSuchMethodError: android.os.Bundle.getString Other methods like game.word.word
Game engines like Quack, OGRE3D, JMonkeyEngine and Blender are used for PC games but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.