HitboxClass
Releases | Documentation
The flexibility of the module allows developers to easily handle anything that needs a hitbox, whether it be a projectile hitbox, melee hitbox, server-sided hitbox, or a client-sided hitbox, you name it!
HitboxClass abstracts all the networking for you, so you don't need to lift a finger in order to access synced client-sided hitboxes. The surplus of methods available to modify the hitbox how you please allows you to really do whatever you want with it. It's powerful, easy to use, and incredibly easy to implement!Itâs well-documented! Everything is laid out in the Github.
Also, everything is 100% type-checked! This allows for easy organization and helping you avoid usage errors!
Automatic Client-Side Replication:
- HitboxClass automatically sets up client-side replication so you donât have to!
- All methods used on the hitbox on the server are replicated to the client!
Flexible Options
-
The amount of options provided by the module allows you to design the hitbox how you want it to function! This includes:
- Calculating on the client vs the server.
- Debounces for same-character hits.
- IDs between hitboxes.
- Dot product checks for magnitude hitboxes.
- And more!
Velocity Prediction:
- Server-sided hitboxes when âweldedâ using the WeldTo method to a part use that partâs velocity to guess where the part is on the client! For instance, if put on the HumanoidRootPart on my character, you can see the difference between a hitbox using velocity prediction and one that doesnât use it!
(Thank you @beansinmybathroom for the method!)
Velocity Prediction Showcase
The hitbox using velocity prediction is shown in green, both are on the server!
Click here if you canât see it!
After setting it up properly according to the Github:
First, require
the module.
Next, setup your Hitbox Parameters:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HitboxClass = require(ReplicatedStorage.Modules.HitboxClass)
local HitboxTypes = require(ReplicatedStorage.Modules.HitboxClass.Types)
local hitboxParams = {
SizeOrPart = 5,
DebounceTime = 1,
Debug = true,
} :: HitboxTypes.HitboxParams
--[[
A magnitude hitbox that can hit anybody, with 1 second between possible hits for each character!
It'll also show itself in red!
]]
Then make a new hitbox with your parameters. The HitboxClass.new
function will return the hitbox and whether or not it successfully connected to the client. This will always be true if this is a server hitbox.
local newHitbox, connected = HitboxClass.new(hitboxParams)
Finally, connect to the HitSomeone signal and start the hitbox!
newHitbox.HitSomeone:Connect(function(hitChars)
print(hitChars)
end)
newHitbox:Start()
HitboxClass does not secure remotes for you!
- Other than ensuring signals fire back only what they list in the documentation, itâs up to you to ensure a hit was within reason. Make sure you validate responses sent back from client-sided hitboxes!
HitboxClass has script-injecting behavior!
- When HitboxClass is first required, it sets up a
RemoteEvent
and adds aLocalScript
toStarterPlayerScripts
, as well as giving theLocalScript
to anyone there before the module is required!
HitboxClass is built for Humanoids!
- If you want to add support for non-Humanoids, go for it! Iâve only ever needed to check for Humanoids, so this module is built with them in mind.
Latest Release (the .rbxm file): Github
All the documentation is here!
Nothing is being detected!
- Make sure the entities you are looking for are in the Alive folder you set. HitboxClass only searches the Alive folder for entities to hit.
How do I secure client-sided hitboxes?
- Ideally you want to use sanity checks, like checking the magnitude between 2 points, to see if the enemy is close enough to the player. Combining sanity checks is ideal in securing your remotes, and should be used outside of this module anyways.
Hereâs a couple examples of the hitboxes in action from a game Iâm working on!
Click here if you canât see it!
Click here if you canât see it!