How do I make an extensible, modular, fast-paced combat system?

Hello!

I want to create a modular, extensible combat system that will be easy to manage and favours user experience whilst also being secure as possible. My problem is I don’t know how to start with something like this and most topics I’ve read are about more specific parts of a combat system.

Essentially I want each weapon to handle animations, visual hitting effects etc on the client as soon as input is received so gameplay feels smooth, whilst also replicating stuff like states, verifying any hit detection the client does etc. I’m trying to come up with a modular way of handling all of this

An example weapon: A sword where if you swing the sword 3 times in a row with less than 0.5 or so seconds between each swing, you perform an ultimate attack.

I understand my topic’s question is very open ended so I came up with a few questions that are leading me to struggle how to begin some sort of system like this:

  • How do I replicate weapon effects quickly to other clients? If I have a sword that can be activated rapidly and is very fast-paced, the time it takes to fire a remote and the server to use fireallclients to other clients for generating visual effects will be too slow as by then the hit animation would have stopped.
  • How do I manage changing states that replicate to the server from the client effectively? In the weapon example I showed above, I want the server to know if the client is currently swinging the sword for the e.g 2nd time in a row before doing a ultimate move as I want to ensure there is no possibility of just firing the remote saying an ultimate move was done every time. My issue is if replication is too slow, how do I verify this? Do I sacrifice this security for user experience?

I’m sure I’ll run into more problems on the way, mostly I’m looking for advice on things I should try to accomplish to ensure my fast paced combat system is as secure yet smooth as possible, extensible (I can add weapons easily without having to write tons of code each time) and modular. Sorry if this is very open ended, I am concerned mostly about having the client immediately act on input but replication being too slow for telling other clients to do this effect etc.

Thank you!

5 Likes

Prototype system for my game that could be modified to fit your gameplay.

Making the move

First you’ve gotta write a function for the move so you can easily create similar attacks.

Properties

Each move has 7 basic properties, possibly more based on the game’s core systems like blocking.

  1. Damage - Damage noob! what else would it be?

  2. Hitstun - How long they will be left vulnerable for combos and such

  3. Knockback - The velocity your opponent recieves upon impact.

  4. Startup - Winding up of your move, uses long anticipation

  5. Active - The part where hitboxes activate and attacks collide

  6. Endlag - Animation comes to an end, leaving your character vulnerable to attacks.

Tip: Use the acronym DHKSAE to memorize the 6 basic properties of moves!

Hitboxes

Now that you’ve got that out of the way you need to find out how to hit the move itself.
So basically there’s 2 main types of hitboxes:

  • Physical - Stuck to the HumanoidRootPart of the player or some limb or appendage (like tentacles)

  • Projectile - Mobile hitboxes and are usually not very limited to the character’s position

Physical attacks are what you’re gonna be using the most often but projectiles are cool too, right? :pensive:

I suggest you place the hitboxes while animating so you can see where you are placing them and to keep track of their timing. Then you can weld it to the RootPart of the animation rig or a part already at the same spot so that you can position it correctly in game.

Magnets

Here, there are some though choices to make. You’re going to need pick which magnet your move uses.

btw you always have the option of not using magnets which is often the best choice for most moves!

  1. Hard Magnets - The opponent is instantly teleported to the hitbox’s position. Use this carefully as it can be infuriating to be 1 mile away and get struck down by a rev sp1.

  2. Soft Magnets - A tug to hitbox’s position. Just a hard magnet but has a pull, delaying it.

  3. Drifts - Similar to soft magnets but way more weaker and have way less of the bs aspect.

  4. Autohit - Moves that will make the next attack guaranteed to hit. Great for attacks with multiple strikes, such as a flurry of sword slashes!

  5. Cutscenes - Cutscenes. Make them look good to reward difficult plays so that the player feels like a badass B)

Put them all together in a function with way too many parameters and you’ve got yourself a move maker! Or you can do something else idk much scripting.

function BasicAttack (Hitbox, Animation, Damage, Hitstun, Knockback, Startup, Active, Endlag, MagnetType, MagnetForce, Autohit)
-- you could make it so that it automatically switch between Hard, Soft, and Drift based on the value if you don't like having too many paraments
end)

For effects you’d need to create another function or multiple that would probably contain parameters such as X Torque or Y Velocity. Try to make as few functions that cover different types of effects like meshs, explosions, beams (underrated, use them!), etc. You get the picture. There are alot but designing for maximum efficiency in the long run will have you thanking yourself later.

A thing I’ve come up with are “Hypercubes”. Honestly it’s a rough idea where there’s a rig with just 1 part attached but that part’s position and orientation relative to it’s RootPart animates other objects in the workspace. Ex: The X vector changes facial expressions, Y vector manipulates sword glow
I’m planning on building a plugin that could easily implement this easily in game systems to make it simple for more expressiveness to happen (not self promoting but sharing an idea)

Move Execution & Hitbox Detection

The next step is finding a way to make the move feel reactive, whilst keeping it fair for both players and removing the power of exploiters.

You can do this by making the move happen first the in client, firing a remote event, executing it in the server, and then comparing the distances between the two to prevent kills from 1 mile away. This also works for cooldowns.

coughs rev sp1 coughs

So on the server’s version of the move executor there are all the technical stuff such as the hitboxes the client has but in addition there should be a max distance parameter added to the move maker function so that each move has a maximum range of effectiveness. Maybe you could even just remove the character animation for the server so there’s less lag?

make sure some attacks have high range preferably without much magnet so that extremely laggy people can at least hit moves and stand a chance against the 0 ping tryhards who live right under roblox headquarters.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

The server should pass on effects and such to other clients so that they can also see the coolness of your attacks.

Conclusion

Anyways that’s about all. Projectiles aren’t really that bad but might be too much to cover one reply.
Thank you for attending my Ted Talk, this was probably a bit too much than what you asked for but it should help you in designing algorithms for your game. C:

side note: take time to make the gameplay is good. planning out a core feature wrong could have disastrous consequences. movement is important btw.

uwu

27 Likes

One thing I would like to point out is that you don’t have to use FireAllClients when activating the effects, just make the effects happen on the server, it’s basically twice the speed.
Well, it depends on what type of effects of course. If you needed to move the camera then in this case you do need it on the clients, however it might be faster to just use FireClient on the player that is being attacked.

Make sure you avoid using functions that yield (things like WaitForChild and LoadAnimation) before the effects of an attack. The stun should happen first, then the effects and then everything else, only have something else before them if absolutely necessary. One of the most important things of a combat system is giving the player visual info as soon as possible, so that they know that the attack landed

The way I order my attack hitting system is like this:
Stun
Effects
Damage
Animations (LoadAnimation is very slow, so it needs to be done last)

1 Like

Apologies for necro but you should absolutely use FireAllClients if you care about optimising the server.

By firing it to the client, you take the load of replicating parts, effects, and such to all clients of the server when the client could perform that same effect locally. While you may have less control over the effect, if you design it properly, it is more efficient and effective to create skill effects on the client.

What about knockback? ive fond that knockback neeeds to be early to prevent overlapping knockback.

You could talk for HOURS about what the best practices for hitboxes and function ordering are when it comes to this stuff, the reason being, there is no definitively correct answer. Sure, you got your don’ts, but I don’t think I’ve come across many universally agreed upon do’s (aside from sanity checks if your running on the client).

How you order things is all completely dependent on how your game works in the first place. Knockback might need to be early in some, and it might need to be later in others. Frankly, for me I do it later. Some games may not even have the problem of “Knockback Stacking” (I’m guessing that’s what you meant by ‘overlapping’), so on that note I can’t (nor anyone else) give you a definitive answer, lest you are using the exact same system as them.

P.S.
Try not to bump posts that haven’t even been commented on for 1+ years; Just kind of a common courtesy.

1 Like

Oh apoligies thank you for lmk, and apprecaite your answer

1 Like