I’ve seen so many big developers with their games achieved this. I just can’t ever figure out what their secret recipe is. What am I talking about?
Games like “Arsenal”, “BIG Paintball”, “Phantom Forces” have guns and weapons that fires immediately without any delay from the click of the mouse to the launch of the projectile (bullets, rockets, you name it).
This is an example of a Slingshot in Arsenal.
Notice how as soon as my mouse is inputted, the ball launches out.
Complete 0 seconds of delay, and the ball does not stutter while moving.
I was trying to do the same thing as they did for many attempts, but none of them seems to work, this is my progress so far:
Local script (This is put inside a “Slingshot” tool):
-->> LOCAL <<--
local storage = game:GetService("ReplicatedStorage")
local remotes = storage.Remotes
local remote = remotes:WaitForChild("Remote_Slingshot")
local localplr = game:GetService("Players").LocalPlayer
local char = localplr.Character or localplr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local tool = script.Parent
local animations = tool.Animations
local anim_idle = animations.Idle
local anim_fire = animations.Fire
local track_idle = hum:LoadAnimation(anim_idle)
local track_fire = hum:LoadAnimation(anim_fire)
function Equipped()
track_idle:Play()
end
function Unequipped()
track_idle:Stop()
end
tool.Equipped:Connect(Equipped)
tool.Unequipped:Connect(Unequipped)
function Fire()
track_fire:Play()
remote:FireServer()
end
tool.Activated:Connect(Fire)
Server script (This is put inside ServerScriptStorage)
--==== Weapon: Slingshot
local storage = game:GetService("ReplicatedStorage")
local remotes = storage.Remotes
local remote = remotes.Remote_Slingshot
local vec3 = Vector3
local col3 = Color3
local shape_ball = Enum.PartType.Ball
local projectilebase = Instance.new("Part")
projectilebase.Shape = shape_ball
projectilebase.Size = vec3.new(0.6,0.6,0.6)
projectilebase.Color = col3.fromRGB(115,56,33)
function FireEvent(plr)
local char = plr.Character
local head = char.Head
local direction = head.CFrame.LookVector
local p = projectilebase:Clone()
p.Position = head.Position + direction*0.6
p.Parent = workspace
p:SetNetworkOwner(nil)
p.Velocity = direction * 150 + Vector3.new(0,50,0)
end
remote.OnServerEvent:Connect(FireEvent)
I also have a RemoteEvent inside the ReplicatedStorage if you have noticed.
Using
p:SetNetworkOwner(nil)
seems to make the projectile stutter for a bit, so I changed the NetworkOwner to p:SetNetworkOwner(plr)
and this is the result so far:
This may look smooth and does not lag, but if you watch the video carefully. You can see that after I click my mouse, it takes about 0.1 - 0.3 seconds before the projectile spawn and starts to launch.
That small number is a big problem because in combat, people with weak internet will notice their ball is not spawning and departing after they input. And when the player moves too fast, this will happen:
But if you look at the first video I posted from Arsenal, they are able to solve this problem. Proving that this is not an impossible problem, but I just can’t figure out how to replicate it.
Do you guys have solutions that can achieve the same thing?