How to add bullet drop

hey, I was working on a gun system, And I was wondering how I would go about making a bullet drop. (Specifically has to work with the raycast) Here is a sample of the ray code:

				local targetPoint = MyMouse.Hit.Position
				local shootDirection = (targetPoint - Handle.Position).unit

				shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
					(0.5 - math.random()) * 2 * Spread,
					(0.5 - math.random()) * 2 * Spread) * shootDirection
				local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
				local bullet

This is a visual demonstration of what I want to achieve.

Thank you :tongue:

Just use a projectile like how many other games do, Alot of people are coding their entire own systems but if you want to be optimized, use roblox’s built in system.

Use the actual bullet as the item then fire it with a linear velocity.

1 Like

how? i apologize, i’ve never made a gun system before lol

I don’t really know I am going to be honest but with my experience, Id say you apply linear velocity to the bullet the second it is spawned with the speed and direction you want, then make it a short burst so after that its moving purely from simulated momentum however it will fall from gravity.

1 Like

A great way to do this is to use libraries like FastCast that simulate curved raycasts affected by gravity (aka bullet drop).

These libraries are meant for your exact use case: doing raycast collision checking for bullets whose path drop over time.

Interesting, How could I implement fastcast to the code I provided above?

You can read the documentation here:

https://etithespir.it/FastCastAPIDocs/fastcast-objects/fastcast/

You’d basically replace your raycast call with a call to Caster:Fire(…) and you’d make the Caster object by doing FastCast.new(). You can also add settings for the bullet drop.

There are probably lots of tutorials on it, and the docs should explain it.

1 Like


Doesn’t work, Returns nil as position.

If you are talking about hitboxes then you can go here

if you are talking about making your bullet being a projectile and having physics then learn about assembly linear velocity and the function BasePart:ApplyImpulse it applies a force to get a part from point a to point b.

some videos:

1 Like

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