I have been trying to do bullet drop for a while and I had an idea yesterday to just spawn a part and use a BodyForce to move the part as if it was a bullet. I figured since this runs with the physics engine inside Roblox it may be less intense than casting tons of rays for bullet drop. I coded this in this morning but I realized the outcome was inconsistent, but the data I input is consistent every time.
See how the bullet lands at a different place every other time.
Heres my code, its currently in a server script because I was just testing.
local Bullet = Instance.new("Part") Bullet.Name = "Bullet" Bullet.Anchored = false Bullet.CanCollide = false Bullet.Material = Enum.Material.Neon Bullet.Size = Vector3.new(.2, .2, 2) Bullet.CFrame = CFrame.new(workspace.BulletSpawn.Position, workspace.BulletSpawn.Position + workspace.BulletSpawn.CFrame.LookVector) Bullet.Parent = workspace Bullet:SetNetworkOwner(Players:GetPlayerByUserId(14112295)) local BulletCollisionEvent = Bullet.Touched:Connect(function(TouchedPart) if TouchedPart ~= workspace.BulletSpawn then Bullet:Destroy() end end) local BulletForce = Instance.new("BodyForce") BulletForce.Force = Vector3.new(0, 50, -100) BulletForce.Parent = Bullet DebrisService:AddItem(BulletForce, .1) wait(1)
If anyone has ever done a physics based bullet system and has any info, please let me know