When firing a raycast bullet from the client, the origin of the bullet doesn’t update often enough and I have seen other games with the same gun type (3rd person to mouse) and update considerably better.
My problem here isn’t that the raycast is firing from an incorrect origin, it does that just fine but when the player is jumping and moving a lot it can be quite inaccurate to where the mouse actually is.
I wanted to upload a 3second clip of this in action, but this website wouldn’t let me… Literally 3 seconds thats all I ask…
local params = RaycastParams.new()
local filter = {}
for i,v in ipairs(workspace:GetChildren()) do
if v.Name:sub(1,7) == 'bullets' and v:IsA('Folder') then
table.insert(filter, v)
end
end
table.insert(filter, t)
table.insert(filter, plr.Character)
params.FilterType = Enum.RaycastFilterType.Blacklist
params.IgnoreWater = true
params.FilterDescendantsInstances = filter
--local Raycast = Ray.new(plr.Character.Head.CFrame.p, (m.Hit.p + Vector3.new(math.random(-spread, spread),
-- math.random(-spread, spread), math.random(-spread, spread)) - plr.Character.Head.CFrame.p).unit * maxdist)
--m.Hit.p + Vector3.new(math.random(-spread, spread))
local Raycast = workspace:Raycast(
t.Handle.Position, ((m.Hit.Position - t.Handle.Position).Unit) * maxdist, params)
if Raycast then
local Position = Raycast.Position
local Part = Raycast.Instance
local Distance = (t.Handle.Position - Position).magnitude
local inner = Instance.new('Part', workspace:WaitForChild('bullets'..plr.Name, 5))
inner.Size = Vector3.new(0.1, 0.1, Distance)
inner.Color = Color3.fromRGB(255, 255, 255)
inner.Anchored = true
inner.CanCollide = false
inner.Material = Enum.Material.Neon
inner.CFrame = CFrame.new(t.Handle.CFrame.p, Position) * CFrame.new(0, 0, -Distance / 2)
local outer = Instance.new('Part', workspace:WaitForChild('bullets'..plr.Name, 5))
outer.Size = Vector3.new(0.2, 0.2, Distance)
outer.Color = Color3.fromRGB(0, 150, 255)
outer.Transparency = 0.5
outer.Anchored = true
outer.CanCollide = false
outer.Material = inner.Material
outer.CFrame = inner.CFrame
game.Debris:AddItem(inner, 0.075)
game.Debris:AddItem(outer, 0.075)
t.gun:FireServer('fire', {{inner.CFrame, inner.Size}, {outer.CFrame, outer.Size}, {Part, Position}})
That’s the code for it and I basically just want the origin to update much faster but I’m unaware on how to do this. If this actually isn’t possible due to roblox engine limitations, which I’m convinced it is, then please tell me.
Any help appreciated!
