Hello
!
Prepare for a long explanation :
I’ve recently been working on a spell system. After doing some research on the internet, I saw people saying to counter the lag, you can get the delay between the client asking to fire the remote, and the ectual event on the server taking place.
But my problem is for example i’m using an animation to hide the latency, the client has a high ping and I remove the delay from the server for the client to be synced with, then other clients will see the spell being fired before the ending of the humanoid animation. Do you understand what i’m saying ?
Example :
In this picture the blue ball, only rendered on the client is taking care of animation,… while the red ball from the serv is taking care of the damage.
This is how I work :
- The client send to the server all the info needed (time(I have a time synced with the server), pos, spell)
- The server receive the event at time BC (before cast) checks if all his infos are correct, and also calculate the delay (D) between sending and receiving. To hide the latency, spell need a time cast (TC) and will be fired after the cast, at time PC (PostCast).
- and 4. Here is the problem, in any case i’ll fire a remote (at time BC) to every client, saying the author of the spell and all useful info (like PC), so they can replicate it in their client. It’s also at time BC (+their delay) that every client will see the author of the spell start his humanoid animation. Now if i want to sync the author and the server, then the spell needs to be fired at PC = BC + TC - (2 * D). But if PC ~= BC + TC, for all the other client, the spell animation will start before the end of the humanoid animation.
So I don’t think there is a way to sync every client to the server, unless i’m missing something ?
Thx for reading !
1 Like
Woah, those are some nice drawings, top-notch
. Anyways, if I understand you correctly you want to send the fireball synchronized on all clients, so it get’s recieved on the server at a specific time. You’ll have a delay sending it, and so you want to cover it up with an animation. Once it reaches the server, it gets send back to all clients in sync? The last 2 paragraphs my head exploded.
1 Like
You’ll have to thank paint3D and my amazing skills for those drawings ! But yes, this is what I want to achieve, I want to cover the delay with an animation and a casting bar. But the problem is if I take into account the delay for the client on the server, then other players will see the spell before the end of the humanoid animation. Is that more clear ? 
In that case, can’t you wait for the server to register that all the player’s events have fired, added to waiting until until all player’s animations have finished. This way all of it is synchronised when received on the server.
But if i wait on the server for the hum anim to end, from the pov of the client which fired the event, the red ball will have a delay (corresponding to the time it takes from the changes made on the server to appear on the client) depending his ms
, which is the same as not taking the delay into account.
Ahh. I just realised that one way you could counteract this visible delay that the client can witness is by using GetMarkerReachedSignal. Since you’re sending an animation as a latency cover up this function could be used on all played animations, which changes when the corresponding marker is reached. This way you could fire in sync to the server, to return on the client.
That’s probably the best way I can think of. If some clients have a small latency, then you just have to make-do with it.
1 Like
This wouldn’t solve the delay between MainClient-Server-Clients but I think as you said, i’ll just have to make-do with it. Because the humanoid animation also takes a delay to appear on the serv, so the end of the client and the end of the server wouldn’t be in sync.
Listening for a key reached in the animation of the client which fired the remote is not the way, the delay will still be present (sorry if I can’t explain correctly but this won’t work, or maybe it’s a misunderstanding on my part about what you are trying to explain).
1 Like
So are you talking about the server returning the animation to all clients? Like I said, you could wait until the keyframe or maker has been reached, and send a remote event from that client. However with that in mind, i’m not sure but the server will definitely suffer latency lag. The clients input can be different to other clients input, and so there’s not a immediate communication to all the other clients that they have reached the keyframe in sync.
I have thought of one thing tho. Yes there is a latency, but since you firing a spell/fireball, there are some ways to work around it. I’m going to go and assume that your fireball is shooting at a fixed position in front of the local player. I’m also going to assume that your velocity of your fireball is constant. I’m also going to assume that your fireball is sent in front of the player. What you could do is spawn the fireball at a close position to the player, calculate the delay time before the event was received from the server using tick() and multiply it by the velocity. If the math adds up, the fireball would match it’s position as when fired from the client. However, this feature can be abused.
1 Like
you can play the animation on the server to make the firing client sync up to the server if you’re fine with compromising the client’s experience
1 Like
I reckon there’s a notable difference playing from the server in contrast to on the client. Playing from the client is more responsive when starting that animation in response to the user’s action. Keep in mind, that there is going to be a latency in regards to the clients performance, ping etc when played from the server. Running from the client is more convenient because they have network ownership over their character, resulting in the animations being able to replicate operating Motor6ds and performance is smooth. Of course you it’s okay to run from the server, dependent on your preferences.
3 Likes