Hey everyone, I really need help on this one.
I am developing a 2d fighting game. Of course, you’d need functional 2d hitboxes in order for the game to work. I’ve hit many roadblocks when it came to this, and attempted a number of solutions.
Method #1: Physical Parts for hitboxes, using .Touched
I first tried using parts for hitboxes, with clear visual indicators like how they would appear in real fighting games.
However, the biggest issue is that hitboxes do not collide consistently. I do not know why this happens.
I no longer have the version history for this build as I’ve scrapped this quickly.
Possible causes:
- Hitboxes aren’t out for longer than a split second, however I’ve tested this with a longer lasting hitbox and it still appears.
- Collisions are handled on the server, and may be inconsistent to player position
- Hitboxes are restrained to 0 on the Z axis, only moving X and Y. I don’t think this should be the issue, but roblox’s physics engine isn’t exactly the best and I suspect that such limited movement won’t trigger any collisions.
It may be unrelated, but there’s a LocalScript that keeps players on 0 on the Z axis. If a player were to move from that point, they are immediately teleported back to 0. I wonder if this has to do with the inconsistent hitboxes.
local function focus(p1root, p2root)
if p1root.Position.X < p2root.Position.X then
return CFrame.new(Vector3.new(p1root.Position.X, p1root.Position.Y, 0), Vector3.new(p1root.Position.X + 1, p1root.Position.Y, 0))
else
return CFrame.new(Vector3.new(p1root.Position.X, p1root.Position.Y, 0), Vector3.new(p1root.Position.X - 1, p1root.Position.Y, 0))
end
end
if lastZ ~= p1root.CFrame.Z then
p1root.CFrame = focus(p1root, p2root)
end
lastZ = p1root.CFrame.Z
Though despite this, this was the method I wanted to work the most. Not just because it is accurate to fighting games, but I can place the hitbox wherever I want. It could be a disjoint, part of a limb, etc.
Method #2: Raycasts from existing limbs, with an adjusted version of Swordphin’s hitboxes
I’ve used this method as kind of a “placeholder” hitbox system in the draft version of my game, and sure enough, it works fine.
Though, I have some issues with this.
- Hitboxes are restrained to player limbs, so there cannot be any disjoints or projectiles.
- Multiple attachments need to be created on each corner of a limb so that the “hitboxes” wont appear skinny
- Rays are cast from the player’s server position, which is an issue because there is latency between the client and the server, so the player will have a millisecond delay on their positions. This will become a problem when I incorporate air combos into the game, since there is quite a noticeable delay in when players “jump”.
This was my placeholder system so I wasn’t intending on using this forever, because of the limitations of where I can place these hitboxes. I wanted to achieve something like the first method where there were actual hit BOXES, mostly so I could use disjoints and projectiles. Here’s an example from Guilty Gear Xrd
If anyone can come up with workarounds or any other possible methods, that’d be great! I’ve been at a roadblock for a whole month!