I’ve been working on a fighting game, and have struggled with a few ideas.
First off, hitboxes. I’ve been using the touched event, which has worked okay, except it can be somewhat buggy, and I also have a weapon that creates a growing effect around the player, and if an enemy is inside this, every tiny increase in size counts as a new touch, so it kills almost immediately. My best idea for alternatives so far is just Region3s and using GetPartsInRegion3 to detect players and go from there, but I don’t know if this is the best option, and I was looking for others that are more effective, or whatever the convention typical is among fighting games and weapons.
The next thing is stuff like stun. The way I’ve done it so far is decreased your walkspeed and jumpheight for a bit before adding it back. I can’t just manually set it, because if you get a speed buff or something the stun will reset that. Also, unless I have a check, if you die with stun, then the timer may go back up after you die and then increase your walkspeed above the base walkspeed. I though I accounted for both of these things, but it still seems to be happening on rare occasions, so I was wondering if there’s just a better way to handle it as well (I’d image there’s a norm that people do, since it’s such a common feature)?
you can use something like workspace:GetPartBoundsInBox , there is a good tutorial by Tekleed and consider using state managers , so you can set and check states of the character, there is a video on it by ArTheDev.
Hello!
Assuming the growing effect is intended to be spherical, WorldRoot.GetPartBoundsInRadius might be a reliable solution. Just make sure you check the parts in an efficient and reliable manner in order to avoid problems.
As for the Stun, you could use ModuleScripts to build a state manager for each player, which would determine what stats the player has.
For example: The state manager would store stats for each player in a table, like this:
local Statuses = {}
Statuses[userId] = {"Stunned","Bleeding"}
From there, you could build a system that adjusts the walkspeed accordingly.
If a player gets a speed buff, the state manager would be able to detect that the player is stunned, and therefore the speed buff would not apply! And you can configure it in whichever way is best for your purposes.
As for the hitbox, the touched event should be fine as long as your checks are robust and you always seek a HumanoidRootPart. You can come up with something more advanced, but it’s usually not essential unless your case truly demands very precise detection.
Edit: As I’ve read, given that your game is a fighting game, it could be practical to replace the usage of “Touched”. That given, you might want to look into using RayCasts or Hitboxes via workspace:GetPartBoundsInBox, as the developer above me suggested. It may be more adequate for a fighting game, where collisions are important.
Godspeed, Fellow Dev!