Make a part go straight forward without it moving

I’m trying to create a gun and I have everything good. The only issue is is that each time it shoots a bullet, it goes down onto the ground.
(example)

Allot of people have said to use bodyposition, but then how do I get rid of the whole position thing? (Prevent the bodyposition from moving the bullet to the set position)

I could really use help!

Try using BodyVelocity.

Optionally, use BodyForce with an upward direction (the same force as gravity) then just set its Part’s Velocity. This negates gravity’s effects on the part and lets you set it’s velocity without worrying about gravity.

6 Likes

They would just add enough power to the body velocity so it would fly if they want it like that.

1 Like

If you use this, here’s how to calculate the upwards force to make the bullet “zero gravity”:

bodyForce.Force = Vector3.new(0, basePart:GetMass() * workspace.Gravity, 0)
5 Likes

I would use RunService.Heartbeat where it casts a ray to check for a target in the direction it’s moving. If theres a target, it damages them ( or whatever you want to happen whenever the target gets hit), disconnects the heartbeat, and destroys the bullet. If theres not a target, it moves the bullet forward.

Keep in mind the bullet would have to be anchored and ideally non collidable.

If you don’t want to use heartbeat, you can just use a bodyvelocity, and set its maxforce to vector3.new(math.huge,math.huge,math.huge) so it doesnt get affected by gravity. You could handle hits through raycasting or the .Hit event

1 Like

Anchor the bullet and move it by its cframe.

1 Like

Thank you! I have been trying to solve this issue for an entire week.

1 Like

If you use this, here’s how to calculate the upwards force to make the bullet “zero gravity”:

bodyForce.Force = Vector3.new(0, basePart:GetMass() * workspace.Gravity, 0)

Thank you, I was already having some trouble on how to do this, then you came!

2 Likes