Calculating compensation for bullet drop

I’m currently using raycasting by frame in a fps gun system, and I have in place bullet drop. I was wondering how to calculate the compensation for said drop, which uses the default gravitational constant?

In other words, what calculation would one do for a phantom-forces-balistics-tracker-esque system that lets the player know where to aim to hit a target on a bullet with gravity?

This is a quite complex process. I’d suggest using resources that already provide such services like accurate bullet drop FastCast because the API is rather simple and is documented well.

PS: You can calculate the bullet drop compensation using a formula like this:

local targetDist = ... -- The target's distance from the player
local velocity = ... -- The velocity of the bullet

local function getHeight()
  return (targetDist / velocity) * workspace.Gravity
end

This should technically work, if your bullet drop system is similar to FastCast’s

1 Like

I’m assuming that fastcast also calculates drop via the gravitational constant, so this should be the same.

so this would work if i aimed at player.Head.Position + Vector3.new(0,getheight(),0) ?

player.Head.p + Vector3.new(0, getHeight(), 0)

^^ This should do the trick assuming you calculate distance using (hrp1.p - hrp2.p).Magnitude
Also note that it might be off by a small amount of studs, due to the heads offset from the hrp.

1 Like

wait arent you doubling the X and Z values by adding it again?

You’re right lol, I forgot that we are already adding it to the heads position. Thanks for pointing it out.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.