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 6787551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:22:47+00:00 2026-05-26T17:22:47+00:00

I hava a Tower with the position Vector2 that shoots a target when i

  • 0

I hava a Tower with the position Vector2 that shoots a target when i comes close enough. The projectile should inherit the tower’s position as it’s startposition and it then gets a target Vector2 that is suppose to hit.

How do I calulate this as i need to calulate the new position in every update when the projectile knows its own position and target position plus speed?

  • 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-26T17:22:48+00:00Added an answer on May 26, 2026 at 5:22 pm

    If you have target and origin, then just doing target – origin gives you a new Vector2 which is the direction. You then need to normalize this direction vector, and multiply it by the projectile speed.

    Pseudocode:

    Vector2 target = objectToShootAt.position();
    Vector2 origin = tower.position();
    Vector2 direction = target - origin;
    
    direction.normalize(); // or direction *= 1/direction.length()
    direction *= speed;
    

    Then just use direction and multiply it by the time between frames, and add this to the bullet position.

    Edit: to follow up on George’s comment
    The pseudocode I showed will always miss the target if the target is moving since it assumes the bullet cannot curve and does not take into account target velocity. If the bullet curves, as George said, you need to recalculate the direction vector each frame.

    To have a non curving bullet but that takes into account the target’s velocity, you need to predict the target’s position, which is done by estimating the position of the target based on its current heading, speed, and the time it will take for the bullet to get there.

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

Sidebar

Related Questions

I hava a WP 7.5 app. I have a splash screen and then comes
I hava a CSV file that I want to treat as source code. Essentially
I hava a form (form_remote_tag) that updates a comments section. The form is in
I hava a function that looks something like this: require(config.php); function displayGta() { (...
i hava a class that hold a list for each request but each request
I hava a php variable that contain JSON type data. $list = [{id:10,first_name:first,mi_name:,last_name:last,nick_name:HH}]; and
I hava a xml doc (and complex element) that is similar to this example:
I hava an application that is in flex 3 and we are migrating it
I hava a TreeView in VB6 that uses a PopupMenu when a Node is
I hava one PPTP server(192.168.1.100/172.17.0.1), and need route all the packets(target ip is 172.17.0.11)

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.