Hi. I am trying to make a gun. I am having trouble with the bullet gravity. When shot it drops because the speed is low. Is it possible to make the bullet unaffected by gravity? I tried looking around the devforum but I couldn’t find anything. FYI I’m not using raycast the bullet is a part.
Try making the bullet massless?
Ok. I’ll let you know what happens.
It didn’t work I actually tried it earlier.
You should try instead having a LocalScript translate the bullets cframe every render step, in the same direction throughout it’s lifetime. The server can tell everybody the bullet’s initial CFrame, and then the velocity.
i don’t have experience making gun games e
Do you have any examples of how I should do that?
Something like this maybe.
game:GetService("RunService").RenderStepped:Connect(function(dt) for _, bullet in pairs(workspace.ActiveBullets:GetChildren()) do local part = bullet.Part local speed = bullet:GetAttribute("StudsPerSecond") part.CFrame += speed * dt -- dt is the time since the last render step (so bullets move at the same rate for every computer) end end) game.ReplicatedStorage.SpawnBullet.OnClientEvent:Connect(function(bullet, cframe, speed) bullet:SetAttribute("StudsPerSecond", speed or 1) bullet.Part.CFrame = cframe bullet.Parent = workspace.ActiveBullets end)
I’ll try. Thanks for your help.
Before I try this do you know how to tween bullets? If so can you tell me how?
I don’t think tweening bullets is a good idea, since you don’t know where the bullet will end up. Somebody could walk infront of it before it ends. Also, it wouldn’t be a good idea to tween the bullet for 100 seconds and see what it touches first to get around that, since it’s hard to get a lot of information out of a tween. Unlike if you manually increment the CFrame yourself, you can adjust things as needed.
Okay I will try what you gave earlier.
Use an upwards-facing BodyForce in the bullet to counteract gravity.
Alternatively, use FastCast. It’s the best of both worlds between raycasting and physically simulated bullets.
I’m not really familiar with BodyForces. Can you give me a small script example?