How do fighting games handle input so well

I wanted to make my own combat system the way those popular games like Jujutsu Shenanigans do ,
However some specific moves like the dashes (besides the front one) and running and maybe the parkour is handled on the client instead of the server with their own cooldowns and all, how does that work, do they have an specific client state handler ? For example in my current system i handle states on the server and have attributes for cooldown.

2 Likes

Normally, as far as I know, Input is detected on the client only to know when an input happens and to fire an event (or similar)
Then everything else is done in the server so it can’t be easily exploited

Basically:

  • On a LocalScript use either :GetMouse(), UserInputService or InputActionSystem to detect the input
  • If the input is detected, fire an event
  • On a Server Script get the event, and do everything else needed like cooldowns and the skill
1 Like

thats true however i noticed in the case of jjs when you arent connected to the internet you can still side dash and all , i could add a function and stuff like that for those specifically but it feels lazy

2 Likes

That means the script is working entirely on the Client as it’s not needed an active internet connection for that, yet that’s unsafe to do if you care with security against exploits and makes laggy players have an inconsistent movement as it’s using your computer to run it and not the servers

1 Like

I wouldnt worry too much about exploiters abusing client sided dashes, I mean they can just teleport really quickly too whatever location they want whenever they want, essentially imitating dashes if they wanted.

What I would do is make the dash movement completely client sided, as for the front dash, make it so when someone attempts to preform one, the client invokes a RemoteFunction, which determines if they can dash, if they can it returns true so the client knows to activate the movement, and then on the server, wait the length of the dash and then do the hit detection.

As for managing cooldowns, you can just use attributes, and you can probably completely manage the cooldowns on the client I feel like?

At least thats how I’ve done it, and it seems to work fine.

1 Like

thank you i keep seeing you on here, i was thinking about that HOWEVER what if the player gets hit while they are dashing or they are running, they would keep on going. I dont really understand the way these games handle those states , i suppose i can send an remote event from the server to the client to stop them from dashing/running

Personally what I do for this is if the user gets stunned, just set an attribute on the character too say their stunned.

This way its way easier to debug, as you dont have to try and debug whatever the heck the remote event is sending.

As of then on the client, you can tell when attributes change, so you could just use

LocalPlayer:GetAttributeChangedSignal("Stun"):Connect(function)

This way you can keep track of the stun on the client.
Also what I would recommend is instead of setting Stun to a boolean value, I would set it to the current time + the length of the stun.

This way you dont have to use a wait to yield your code, and then disable the stun.
Heres an example of how I did it:

function Class:SetStun(Target:Model | Player, Stunned:boolean, Length:number)
	if not RunService:IsServer() then return end
	
	Target:SetAttribute('Stun', if Stunned then tick() + Length else 0)
end

function Class:IsStunned(Target:Model | Player)
	return (Target:GetAttribute('Stun') or 0 ) > tick()
end

basically what this does is stores the current time (tick() in this case) and adds the length of the stun to it. Its pretty simple I feel like, but It works so well, and its how I do cooldowns and other things like it.

2 Likes

yeah thats actually a good method, im thinking about simplifing it down to base mechanics and just throw stuff at the wall to see what works , thank you blud!

1 Like

after a few hours of research your method is close to the best result, from my time of checking the code of other battlegrounds games i come to think that the best possible solution is using attributes.The client will check if the value of an attribute has changed , and if it does it will update the needed requirements, like for example if you are stunned you cant run , now i had the question of , “It works if you check beforehand but what if you are stunned mid run?” now here comes the solution of stopping the running function when the stunned attribute changes value to true. Thank you for your help FroDev you pushed me towards the right way . I hope ill help you one day the same way you helped me

3 Likes

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