Preventing projectile delay?


#41

I suggest having one remote event for each player that would handle client > to server requests, and a single remote event for all players that would handle server > client requests as many players firing the same remote event can throttle your code.


#42

Throttle your code? What does that mean


#43

There was a post about a game that sent all its traffic through one event, the game performed very poorly


#44

I see.
Then I guess vsnry’s method makes sense
so thanks for clarifying


#46

Using some calculus, you can actually make the clients and server be roughly in sync.

You need to adjust the projectile speed based on the latency of the player, though, so it’s a lot of math.

Working example:https://www.roblox.com/games/498817078/Armoured-Assault-Tank-Warfare-ALPHA-TESTING


#47

I HEAVILY suggest watching this gdc talk about networking Halo
https://www.gdcvault.com/play/1014345/I-Shot-You-First-Networking
Don’t even consider working on this problem till you have


#48

You can sync the server and client completely if you were to send timestamp of when the bullet was fired.
Example code:
*wrote this in devforums themselves, sorry for the formatting and if there are errors, it’s just a representation
of how I tackled this issue.

  -- Client
  remoteEvent:FireServer(tick())
  --Server
  remoteEvent.OnServerEvent:connect(function(time)
    Projectile.new(time)
  end
-- Projectile
local Projectile = {}
Projectile.__index = Projectile

Projectile.new = function(time)
  local self = setmetatable({
    startTime = time;
    start = A, --> Should be passed as well in remote call, but lets say 
    finish = B, --       we're firing from A to B.
    velocity = 80,
    currentPos = A
  }, Projectile)

  coroutine.spawn(function()
    while true do
      local t = wait()
      self.currentPos = self.currentPos + CFrame.new(self.currentPos, self.finish).lookVector * (t * self.velocity)
    end
  end)

  return self
end

return Projectile

#49

Hm I was under the impression that time() wasn’t guaranteed to be synced between server and client?


#50

Isn’t os.time() seconds since the unix epoc? that ought to work


#51

It isn’t millisecond resolution, which is what you would need to do something like projectile syncing using only timestamps

AFAIK, the only way to make this work is to use latency with tick(), since tick() isn’t guaranteed to be synced across server and client. Correct me if I am wrong, though.


#52

My team had a similar problem attempting to nullify projectile delay’s until we found an API created by a prominent member of the Roblox Developer Forum known as Xan_TheDragon. He created a useful API known as “FastCast”; which in practice eliminates projectile based gun physics lag on the server’s end. The whole thing operates off a modulescript API libary which allows for complete customisation from the ground-up.

You can grab it here:

Hope this is helpful.


#53

Hey guys, back again!
Attempted to make the Spell’s parent be the Client of the individual players etc. But having no luck, the only argument that seems to pass is setting the actual LocalPlayer [The Caster themself] as the Parent of the spells.

How would I do this?


#54

for it to only exist on the client you need to create it from within a local script


#55

I’m back again! Ran into more issues that have appeared for some reason?

When creating the new spell and setting it into the localPlayers Character, it’s doing so across the WHOLE server - So because of this, when I’m trying to insert a single spell it’s creating one for every single Player, how to avoid?


#56

Could we please see your code on how the client deals with events fired about spells, and how you fire these events?

From my first assumptions, I believe when someone is casting a spell, you are probably using :FireAllClients() to indicate to all clients this spell has been cast?

I think what you need to do inside the OnClientEvent is to check the player argument, which can be sent by the server, and parent it to the actual player who sent it, rather than always the LocalPlayer.

This is all based off assumptions as I haven’t seen any code, but this is one possible reason why it’s happening