In these games, the bullets bend when they fall from gravity. I have a video here from Big Paintball of the bullets if you don’t understand what I mean. robloxapp-20231102-1755240.wmv (1.3 MB)
I’ve tried using a ball with a trail but it doesn’t really have the same look at all.
So How do I recreate this? Thanks.
Is what you’re referring to an arc in the bullet based on the gravity applied? Could you also provide a code snippet example of how you’re implementing the projectile?
If you want to attempt this without using someone else’s work, you can calculate projectile motion over time and raycast to the bullet’s destination every frame (I highly recommend doing this locally because it will appear smoother).
Some (pseudo)code:
local runSvc = game:GetService'RunService';
local bullets = {};
local gravity = -9.81;
local v0 = 1000; --initial velocity
--on bullet fire:
bullets[bullet] = {
origin = muzzle.CFrame;
progress = 0;
pos = muzzle.CFrame; --use the positional and directional values of the muzzle's cframe to calculate the entire projection. obviously wont work if your muzzle is aesthetic
};
--constantly running
runSvc:BindToRenderStep('ballistics', 0, function(dt)
for bullet, cfg in bullets do
cfg.progress += dt;
local newPos = cfg.origin * CFrame.new(v0 * cfg.progress, gravity * cfg.progress ^ 2, 0);
local cast = workspace:Raycast(cfg.pos.Position, cfg.pos:ToObjectSpace(newPos).Position, params);
if cast and cast.Instance then
--ask server to deal damage if recipient was a player
bullets[bullet] = nil;
bullet:Destroy();
return;
end
cfg.pos = newPos;
end
end);
Note that bullet, muzzle, and params are not included, this is only the baseline for projectile motion. Many necessary elements are missing for a proper projectile system.
I’m not really looking for the arc. I just want the bullet to bend. I’m making a paintball gun, kind of like Splatoon, and I’m making close range guns so I want the bullets to be visually obvious that they’re bending. But thanks though.