How do I make an archer NPC adjust their aim depending on how far away their target is so they always hit them?

  1. *What do you want to achieve?
    I have an NPC that shoots an arrow at their target, and I want to make it so they will offset the position they shoot their arrow at depending on how far away they are from their target so that it makes up for the arrow being pulled down by gravity.

  2. What is the issue?
    I have no idea how to figure this out. Currently the NPC just shoot their arrow directly at their target, but it doesn’t reach their target because it hits the floor first. A video of what I mean is below (sorry for bad quality, used roblox built-in recorder)
    https://www.youtube.com/watch?v=aBxCtBcKiJY

  3. What solutions have you tried so far?
    I’ve tried using the magnitude between the two positions to figure out the offset as well as the projectiles horizontal speed, but I can’t figure out a consistent way to make sure the arrow hits its target. I’ve tried looking up online and I can’t find anything similar to what I’m looking for.

Any and all help appreciated!

1 Like

This solution was posted after I made my post.