Faking inertia with projectiles in endless scroller.

I have a kind of endless scroller where the player and the camera are continually moving along the world z-axis. The player throws projectiles where the player clicks the mouse (based on a raycast from the camera). The projectile will move toward the clicked destination just fine, but it will appear faster if it is thrown behind the player character and slower if thrown in front of the player character (because of the constant motion).

To fix this, I added the constant motion of the z-axis, but now the projectile obviously misses the target location. I know there is a simple solution to getting the speed correct and the accuracy right, but I am completely blanking right now. Help?

Thanks.

With the addition of the momentum in the z-axis you have pretty much re created how throwing projectiles works in real life.

So if you want players to still hit their mark you will either need to make them aware of the fact that aiming requires a bit more thinking i.e. aiming straight down to hit something down and right etc.

Or instead of the projectile go towards where they click, make it move to a point in front of the click point. How far in front will be some maths on how far away the target is and how fast the projectile is. This will always hit that position as it moves away from you but it ‘may’ look weird as the projectile leaves the player.

Or alternatively even make the projectile curve and home in on the point clicked if that satisfies how the game works.

So tldr

  • Tell the player to account for the inertia
  • Do some aim correction for them
  • Change how projectiles work