How to remove delay in knockback script?

I am attempting to make a knockback system for a combat system. In the combat system there is a small delay that makes the knockback look like the player is lagging. This delay is especially prevalent in the dash attack where it looks like the hit player teleports. This delay only appears on the attacker’s screen while the hit player’s screen moves normally. Additionally, this is all done on a local script. I have attempted using tween, body velocity, linear velocity, and assembly linear velocity, however the lag remained. Could anyone please help me with this?

Alright, so this is tricky, there are quite a few ways you can solve this. For the sake of things I am going to do the simplest.

Any kind of ability that can knock back, the knockback part is going to need to be server side certified and managed. You will want to temporarily lock the player that is getting knocked back, and give the network authority to the server. Then let the server perform the actual move. Then release on resolution. This will have some stutter in it but it will be better then what you have.

Otherwise, the solution of this problem gets exponentially harder. And you will need to look at doing a soft Deadlock / Rollback like action system.

Your issue is how tightly some things are bound to network authority and roblox. Basically, when you perform your knock back, the server is having to resolve all of it, move the other player, then that player moving is replicated back to the client.

– I don’t recommend this, but this is a solution you can do.
– If you 100% assert that the knock back is valid, when the person performing it does it, you can copy the other players avatar, make their live avatar invisible locally, and then move their copy to where you expect them to show up from the knock back.

Then you resolve and swap the dummy out for the real player. This isn’t really the best option as this is still open to a ton of lag related artifacts and resolution issues, BUT BUT it will get the effect you are trying to do with the more minimal level of work.

You are running into the issues even the big boy AAAs have to worry about when it comes to lag artifacts and prediction and resolution. Bare that in mind, ESPECIALLY when you introduce things that can temporarily render a PVP opponent disabled in any way its really important how it feels etc etc… blah blah ranty old man programer stuff.

I know you may not like it, but I suggest thinking about designing around no knock backs. As, from a technical point of view, it increases your difficulty level of implementation by an order of magnitude.

Part of the issue is, you must remember that a players character authority is actually a hybrid server client authority. So the other player you are hitting actually has authority of their character moving and server. Which is why it lags so hard because the thing has to go to the other opponents client and do the things and then report back the resolutions that then get replicated out. So you are eating a 4x travel cost before the local player performing can get the resolution update. Which is basically 2 TT or (Total Travel Times) before you get the update. So lets say your ping is 60

And the other players ping is 150.

AttackPlayer → Server(30ms), Server → HitPlayer(75ms), hitplayer → Server(75ms), server → AttackPlayer(30ms).

This makes for a total travel time to get your update at roughly 210ms per position update.

Remember ping is representation of TT, or time for a packet to go to the server and then come back in one cycle on average. So half of ping represent the speed in which a packet travels one way.

Thank you. For this combat system I’ll probably hold off on making a complex knockback system, however soon I will try your solutions.

Probably your best bet, I know that sucks but depending on your age, remember that restrictions are just frameworks to get creative in disguess. Knockback will not make or break your game. If it does, I can get on discord with you, and describe the work you will need to start doing to solve it for real. But again, if you are not extremely versed in the more common networking structures like Rollback/DeadReckining/ect… it’s going to be a huge learning experience with a lot of fighting and learning.

Trust me, I ran into an issue where my game couldn’t function properly and would feel terrible without the changes, and it broke my brain to overcome it. I did overcome it but at great time cost.

fire the knock back then delay the damage, server lag is always annoying to deal with when talking about knockback

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.