I’m trying to make a combat system similar to Sekiro, so players can deflect attacks by blocking right as the attack lands, as well as dodge attacks and block them.
This is my plan so far:
- Player clicks to attack
- A remote function is sent from the client to the server, verifying it is possible
to attack - Server checks the players stamina and whether or not their current state makes it
possible to attack (falling, dead, already attacking, etc) - Client gets the go-ahead, plays animations, begins raycasting at a defined
keyframemarker in the animation, stops raycasting at another keyframemarker - If ray hits something, check if it’s a character and check if it is possible to hit
it in it’s current state. Send remote function to the server verifying that
the attack could realistically hit - Server checks distance between players, if the distance is larger than the weapon’s
defined range, deny the attack - If the attack hits according to the server, check the condition of the hit player.
Do logic checks to check if the hit player is blocking, deflecting, or dodging - Depending on the result, send a graphic event to all players within a certain range
to render particle effects and sounds. - Update player values accordingly
Is this an efficient way to do this, or is there some service or something that could make this better?