Been trying to figure out how to do bullet drop with ray-casting for a while now, need some help

I tried seemingly everything, The pages i found about this subject did not give a very good explanation. Can someone explain to me how to achieve this? I cant find any quality sources to help me out. And it appears I have been working on this for over 6 hours now, its driving me insane because I don’t know what else to do.

Code:

local Bow = script.Parent.Parent
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Target
local Range = 500

Mouse.Button1Down:Connect(function()
	local MouseRay = Mouse.UnitRay
	local Current = Bow.Handle.Position
	local Goal = MouseRay.Direction
	for Num = 0, Range do
		local RayCast = Ray.new(Current, Goal * Num)
		local Ingore = {Player.Character}
		local Hit, Pos = workspace:FindPartOnRayWithIgnoreList(RayCast, Ingore)
		local NewPos  =  Current + (10 * Goal) - Vector3.new(0, .5, 0)
		Current = NewPos
		if Hit then
			Bow.DMG:FireServer(Hit.Parent)
			break
		end
	end
end)

Any advice?

1 Like

Why do I even bother. No one will know the answer, I’ll try another 6 hours tomorrow.

Try using fastcast it is great :thinking:

1 Like

Have you tried this? (FastCast can work as well)

Please don’t expect a fast response within 7 minutes of creating your post, not everyone will rush to help you.

1 Like

Sorry i haven’t sleep in 3 days, just feel asleep apologizes for acting like that. I have tried that post and it was no help.

Hi!
I know this is an old topic but better late than never!

The script you provided works as you intended, assuming you put it in a local script inside a tool. You may be having trouble with the remote event.

However, I must raise my concern that Projectile Trajectories usually follow the path of an Exponential function rather than a straight line.
To fix this I suggest using this code

local NewPos  =  Current + (10 * Goal) - (Vector3.new(0, math.pow(1.005,Num), 0) - Vector3.new(0,1,0) )

in place of

local NewPos = Current + (10 * Goal) - Vector3.new(0, .5, 0)

You can also change the numbers inside of the math.pow function to your liking.

1 Like