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
^^ 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.