how do you do it in your game? is there a event we can connect to in the client?
I am not an expert yet on chickynoid but maybe I can help you since I am right now looking and reading the weaponâs code to learn about commands and lag compensation
I am not sure if theres an event for what you are looking for, but from where and when are you wanting this event to fire and connect
The replication behavior should be done like this
- Client sends command and executes client code to make it feel responsive (client equips)
- Server recieves command and executes the server code
- Server sends command to all clients so they can get any changes replicated if they need to (for example weapon models being on characterâs hands, stats that need to be read by the client, etc.)
- Other clientâs recieves command and execute the code (display the effect on everyoneâs clients)
@MrChickenRocket
I finally had free time to read about chickynoidâs code and figure out what makes it tick so I can use the techâs provided for mods to develop my game
Last time you told me commands existed on chickynoid, these were signals that constantly fire the server to make sure the server can know if we lost connection for these signals and then stop doing whatever it is doing to make network rollbacks to the client less confusing, I cannot seem to figure how they work as they seem to be hardcoded to the character controller itself and they arent a thing you can create from what I could find out, what must I do to create my own commands via chickynoid for actions such as charging an attack.
I read also decided to research about why you used delta compression, I found out that it is due to delta compression making the server and client go through less stress by compressing the data they send to each other making, This way it is faster to send and also stresses less the server specially when you are firing it every tick, Is there a way I can use the delta compression chickynoid uses for your own remote events or in this case does chickynoid even has custom remote events? (Normal signals that only need to be fired once)
Also I found out what exactly you meant by me playing the animations from the server by reading into chickynoid, and yeah I didnt knew chickynoid had a fully working animation server which replicates animations to clients which will certainly come in usefull as it makes it faster to work on netcode for games.
And the last thing I wanted your take on is how can I safely do a charge mechanic for attacks, and how can I properly lag compensate via time stamps?
From what I read lag compensation can be done like this in the simplest example: You fire a gun, so you press the shoot button, which then takes lets say it takes 100ms to get to the server which means if we raycast from the server its not even gonna work because its already late, so the client sends a time stamp that says when they started shooting, then the server recieves it and rewinds all hitboxes to that time but heres where I fail to see how this exactly works.
If we rewind the time to when the client started shooting it would still make no sense because the client gets the positions of other players late, meaning if we send the time when we started shooting, what we saw ourselves as the client was already delayed so it wouldnt match with what the server logged at that time, I have read many articles and none leave this clear neither do they leave clear how do they even put a time stamp, is this time stamp real world time? if so it wouldnt even work because all clocks are different and have diff time zones.
and even after understanding this, how do I even properly lag compensate something such as an attack charge, you cant just let the client time stamp when did they started charging and when did they stopped charging because a client can just say oh yeah i started charging â10 seconds agoâ and then later say âI stopped charging 0 seconds agoâ on the commands, so now the cheater got away with +10 seconds of attack charge by just lying with the time stamps which makes his attack charge instantly to full.
What can I do about the problem of charge mechanic networking, its really breaking my head and the max I could find is a post of someone lag compensating a bow charge with doesnt even adresses these problems and uses the ping method which can also be spoofed by making the thing that replies back to the server delay to make it look like we have higher ping when all other requests go as fast as possible.
Roblox made a internal method called workspace:GetServerTimeNow()
, it syncs well on the server and client, you can use this for ârewinding hitboxesâ.
For rolling back in time, every frame you cache the current ServerTime using the internal method I talked about above, this will be really useful for hitting players who are in the past, because your character is in the âfutureâ. You create a bounding box with the playerâs name along with the ServerTime, for example Player.Name.."_"..ServerTime
, after a second their bounding box will be deleted.
This may sound that it could immediately kill a server, thereâs a small replication trick âhackâ, you will create a WorldModel that is parented to the game WorldModel.Parent = game
; this will not replicate clients which will save bandwidth.
WorldModel is also a WorldRoot which means that you can use raycasts and spatials queries ( GetPartBoundsInBox).
For charging: you wonât need lag compensation because itâs just like a projectile with physics, lag compensation is only useful for hit-scan projectiles.
For hit-scan: When a player fires, make sure they send their ServerTime and use that time to raycast against any bounding box who is named after the ServerTime, you can use string.match
to get the bounding boxes. Unfortunately raycasts have a limit of 5000 studs and are expensive if they are long, so you should come up with a clever solution to cover this up for people playing your game like âbullet range is 400 studsâ in the gunâs stats.
Roblox also has a internal function that gives you a Playerâs ping without even using RemoteFunctions/RemoteEvents, unfortunately this only works on local scriptsâŚ
I hope this can help you give an idea on how to implement hit-scan lag compensation.
Thanks for the reply its still helpfull since it cleared some questions I had
I finally found an article that goes indepth into lag compensation after 2 weeks
The article explains that a better trick to compensate for latency is every time you send the world state to the client you send the server time on it too as a time stamp, whenever the client shoots you basically grab the current world state provided by the server, take itâs time stamp and send it back to the server, the server then checks 2 things
Did is the time stamp sent earlier than the last one?
And how back does the time stamp goes (limit is usually 2 seconds to prevent exploiters from rewinding players out of walls before they took cover)?
Also for charging I do need lag compensation, We need to know when did I originially charged since the charge system works like this:
The longer you charge the more dmg you deal, if we do not compensate the time we started charging then we will get extremely inacurrate charge dammages, but again exploiters can abuse the lag compensation and get away with extra charge time which grants them more dmg dealed, without even having to fully charge.
Also for charging I do need lag compensation, We need to know when did I originially charged since the charge system works like this:
The longer you charge the more dmg you deal, if we do not compensate the time we started charging then we will get extremely inacurrate charge dammages, but again exploiters can abuse the lag compensation and get away with extra charge time which grants them more dmg dealed, without even having to fully charge.
You can simply decide when they charged and when they stopped charging on the server instead of relying on the client for when they started charging. You donât have to send a timestamp over the remote, in the server you can use RunService.Stepped to increase the time of the charge until they bash into something. Make sure to disconnect the RunService connection to avoid any memory leaks.
The charge will basically be a raycast in front of the player each frame on the server using RunService.Stepped, at this point the server already knows that youâre charging.
This will not work, you cant let the server just decide.
Imagine you start charging and your latency is high like 300ms so you tell the server start charging, then you tell the server ok i wanna stop charging now after 1 second of starting charging, but now you have a latency of 100ms, the first packet will arrive sloweer and the last one faster causing the server to think we charged for less time
Woo, a little bit of incomplete information in the last few posts.
Chickynoid already has a simple weapon prediction model that would be sufficient to make charged attacks with just a mod.
The weapon prediction is simple in that it only ever predicts the client state forward with no rewinding if it gets things wrong, but itâs more than good enough for handling a player view weapon and bullets, because rewinds on that would look strange anyway. All you have to do is let the client weapon know when itâs safe to sync to the server view of things eg: I hit reload or I stopped firing a burst of machinegun fire. You can see the existing machinegun client code do this when it sets a timer after the last shot is fired - a small time elapses and then it syncs to the server view.
As for doing a full physical state change like winding up a fireball attack, that requires a movetype mod, like the example movetype flying.
Also, chickynoid already has both hitscan predicted weapons and projectile predicted weapons. You donât have to code any of that logic.
so you are telling me I should instead predict when a player will charge again?, but how thats just not possible I mean think about it, how can you tell a player is gonna start charging?, I dont get it, why not just use lag compensation to tell when he originaly pressed click and let go of it and get the accurrate time, Could I get an explanation because im just so confused about prediction now.
Also I should have been clear on what type of game I am trying to make to maybe clear things up, This game is based on Untitled Melee Game, The mechanics are simple:
- You can click to do a light hit which is faster and does less dmg
- You can hold click and after 0.1 seconds it will start charging your attack (it has a limit tho)
- Let go of of click while charging to perform your hit
- You can block by pressing right click which can be held, blocking will also cancel your charging
- You can unblock at any point by letting go of right click
- Press Q to shove.
Shoving a blocking player causes him to stun so you can hit him
Hitting someone while he is blocking causes you to get stunned
It was originally a project written because at the time it seemed simple and I was just starting on learning scripting, then I started making it better, and better, at V4 it was actualy functional but it had issues with the anti cheat systems I implemented, because cooldowns were trusted to the client, same with hitbox and charge mechanic, it only checked if you were doing a state already to prevent blocking while hitting for example
Then I found out about valveâs server authoritative movement, and then chickynoid, I became facinated with the whole concept and since I always tried to do everything super secured I ended up rewriting the game for a 5th time with chickynoid.
Have you considered looking into luauâs new parallel feature for Chickynoid? My apologies if you already use it but I couldnât find any references (other than in the .toml) on the Github.
I doubt chickynoid could be written on paralel luau, from what I read module scripts do not work as data that can be accesed from any script there, because any thread has their own copy of the module which does not syncs with other threads, meaning data stored by a thread in a module is non existant to other threads and chickynoid seems to be relying on the global behavior of modules a lot.
I just made a mod for chickynoid that adds footsteps that change according to the material you step on, Im posting it here because I think its neat and maybe someone is looking to add something like this to their chickynoid game.
Also calculations are completely client sided so it doesnt relies on the server to play the SFX.
Since Chickynoids is being sponsored by Easy.gg, are there any plans to make it fluent with the Knit framework? The code architecture in both systems vary a lot, and it would be amazing if Chickynoids worked alongside Knit.
I ask this because right now, Chickynoids has a very âinterconnectedâ structure where removing one feature would require removing itâs references from all itâs ancestor scripts. Thereâs Chickynoid, then ServerMods, then Weapons, leaving out the intermediates.
It would be really beneficial I think, if features were more independent like how it is handled in the Knit framework, where each feature has itâs own controller, which can grab a service and function accordingly.
Iâm pretty sure thatâd require a complete rewrite.
True. But if it worked with Knit, games could be so clean and modular, along with server authoritative systems. Too good to be true.
Also If I can comprehend the antilag or how Chickynoids handles rollbacks of feature modules, Iâm sure I could rewrite it.
Alright Iâve broken it down to itâs barebones, turns out it doesnât take in input but rather takes clientâs position for sanity checking. Thatâs interesting.
I have everything figured out except updating a playerâs position from outside the chickynoidâs âServerModsâ modules.
I still have to experiment messing with the physics. Chickynoids might try to revolt and rubberband the player back.
Youâre allowed to set any of the chickynoid.simulation variables directly on the server and theyâll be authoritative, position included.
Do you know in what script the thing that makes chickynoids send requests from client to server is?, ive been trying to find it all day by inspecting how weapons send a command and I go from module to module, first I had to read how registering mods work, then a bunch of other things and I keep going arround in circles.