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

  • SEARCH
  • Home
  • 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 7683195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:44:23+00:00 2026-05-31T18:44:23+00:00

Homing/Chasing Algorithm. I’ve been working on this algorithm, for my game. the only chase

  • 0

Homing/Chasing Algorithm.

I’ve been working on this algorithm, for my game.
the only chase i know is the standard Follow the X/Y Coordinates.

Enemy = Chaser

Hero = Being Chased

both Enemy and Hero move at the same time.

the problem is that Enemy the will go in straight line but eventually will not go directly to the Hero. i think its because of the constant value that i use,

Ex:

x = x - 5; or y = y + 5;

how do i determine what value i Add/subtract to make the Enemy chase directly to my hero?

is there a Formula to do that? or conditions?

Thank you.

If there are post that are the same as this, please direct me there. Thank you.

  • 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-31T18:44:25+00:00Added an answer on May 31, 2026 at 6:44 pm

    If your Hero is at, say, (99,50), and your Enemy is at (102, 55), it will move with 5 complete pixels, so it will end up at (97, 50), at the other side of your hero.

    To solve this, you can check the difference between Hero.X and Enemy.X before the move. If the differency is less then the step you’re about to take (5), don’t move the whole 5 pixels, but move only that difference. Repeat that logic for Y.

    I’m not sure what exact algorithm you’re using, but it seems to me that using this logic, the enemy can move Sqrt(2) faster when they move diagonally. Maybe you should consider using directions (angles), combined with a speed. It will be a little harder, using a little goniometry, but movement is more realistic.

    You can take it a step further and try to predict at which point the Hero might be at a certain point in time, so the Enemy doesn’t move to the point where the Hero is now, but tries to cut the corner a little.

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

Sidebar

Related Questions

I have a game I am working on that has homing missiles in it.
Hoping this is trivial for a SQL-Ninja... Been trying to get the following query
This has been an ongoing struggle for me for the last four days. I
hoping this hasn't been asked before, but I have the following XML: <Company id=1000
Hoping I can get some architectural advice on this. I have been given the
Hoping there's been a best practices way to accomplish this so far. Basically, I'm
Hoping someone might know the explanation for this inconsistent behavior. I have had this
Hoping someone can shed some light on this: Do lookup tables need their own
Hoping that using something like this demo it is possible to drag items within
Hoping someone can clear this up for me. Let's say I have 2 globals:

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.