Current Version: V.3.2 Stable (11/18/2020)
- Accurate, performant, and easy to use!
- Use attachments or vectors to make your hitboxes in seconds!
- Attachment pairing to create straight-line hit detection!
- Support for individual part hit tracking or humanoid only
- Hitbox distinction (for example, smash bros tippers!)
- No credits necessary and full help support available!
Upgrading from 2.0 to 3.0
- OnHit events no longer needs to be disconnected as the issue of multiple damages is fixed. Please do not try to disconnect OnHit as the event is now managed entirely by the module and doing so can break certain functions.
Hi there! I just released a module that focuses on raycast hitboxing, so things like melee weapons will probably be the most useful. But feel free to let me know what other projects you will use this for!
RaycastHitboxShowcaseV3 (1).rbxl (101.6 KB)
(do note that these places won’t be updated, so if this module gets an update, you have to do it)
Original Post & Examples
A few years back, I’ve been intrigued by the design of MORDHAU and Chivalry since I wanted accurate hitboxing while making it simple to do across a variety of different weapon shapes and sizes. Here’s a timestamp of how MORDHAU did their hitbox for their swords which may prove to be helpful.
Warning: Does include realistic depiction of blood so please be aware before opening
It basically fires a ray from an attachment placed on the weapon every frame. Do note that the red lines are visualizations purposes only, they do not last that long.
I also made it so you can adjust the placements of where the raycasting starts via attachments so I can fit it on different weapon shapes easily without hardcoding it. Here is the same system but the attachments are spread out a little to compensate for larger hitboxes.
How To Use
Thankfully, it is very simple. Head over to my Github wiki which has extensive documentation and examples that will get you up and running in less than a few minutes!
Why Raycasting over Touched, Region3, etc… ?
I had a little thought process on the end of this thread, so you can check it out if you’re curious on why I opted to go for raycast.
- HitStart only hits a target once (so multiple rays don’t hit the same target). Call HitStop to reset this target pool so you can hit the same targets again.
- No multi-hit support (or Multi-hit support if PartMode is enabled)
- Wide objects requires a lot of attachments to be working correctly
Current Version V.3.2 Stable (11/18/2020)
- HitStop switched to table.clear, for much better table reuse performance
V.3.1 Stable (11/14/2020)
- New OnUpdate Event
- Switched AncestryChanged to CollectionService to fix memory leaks
- Removed RenderStepped sync rate
- Fixed some inconsistent signal error messages
V.3.0 Stable (10/15/2020)
- New Hit Distinction group feature
- Significantly improved hit detection performance
- No longer need to disconnect OnHit events!
- Everything should now be ipairs
V.2.3 Stable (10/13/2020)
- Removed redundant function calls in MainHandler
- Significantly improved HitStart/HitStop performance
- Removed CollectionService ‘RaycastEnabled’ tag (if you were relying on this, it is no longer supported)
- Fixed inaccuracy issues when a hitbox was deleted
RaycastHitboxV2.rbxm (9.0 KB)
V.2.2 Stable (8/22/2020)
- Added WarningMessage bool
- Minor performance improvements
- Folder/readability reorganization
- Documentation improvements
- GetHitbox returned
V.2.1 EXPERIMENTAL (6/05/2020)
- Now uses new Raycast API!
- Removed Hitbox.ignoreList
- Added Hitbox.raycastParams
- OnHit now returns 3 arguments: hit, humanoid, raycastResults
V.2.0 EXPERIMENTAL (5/30/2020)
- Removed RaycastHitbox:DebugMode
- Removed HitStart([damage value]) argument
- Removed DontCheckForTransparency
- New HitboxObject:DebugMode
- Major Performance Improvements
RaycastHitboxV2.rbxm (8.4 KB)
V.1.53 BETA (4/03/2020)
- Updated some outdated API
- Clarified some troubleshooting steps
- Added a new troubleshooting question
- Added warnings whenever it detects rays are not being shown
RaycastHitbox153.lua (17.9 KB)
V.1.52 BETA (3/25/2020)
- Fixed LinkAttachment position errors
V.1.51 BETA (3/24/2020)
- Fixed SetPoints position errors (should now be as accurate as attachments)
- Credits to @Shurikanz for the find
V.1.5 BETA (3/23/2020)
- New HitboxObject:RemovePoints
- New HitboxObject:LinkAttachments
- New HitboxObject:UnlinkAttachments
V.1.3 & V.1.4 BETA (1/28/2020)
- Initialize should now return a hitbox and not nil
- Mild performance increases
- New Function: PartsMode (documentation is in the script)
1.21 BETA (10/30/2019)
- Removed RaycastHitbox:HitStart
- Removed RaycastHitbox:HitStop
DebugRays remade with constraints/attachments to help low-end devices
- Initialization performance improved
1.2 BETA (10/27/2019)
- New HitboxObject:SetPoints(Instance part, table vectorPoints)
- New RaycastHitbox:DebugMode(boolean true/false)
- Recursive now supports all instance types (no longer have to be a model!)
- Ignore list now automatically includes Terrain
1.1 BETA (10/24/2019)
- Deprecated RaycastHitbox:HitStart
- Deprecated RaycastHitbox:HitStop
- RaycastHitbox now returns HitboxObject
- New HitboxObject:HitStart
- New HitboxObject:HitStop
- New HitboxObject.OnHit:Connect(Instance part, Instance humanoid)
- New RaycastHitbox:GetHitbox(Instance model)
- Possible Issue - Heartbeat loop might not successfully disconnect when deinitializing, but happens sometimes (need confirmation)
- Initial Release
Like this module? Please consider donating a little to support my future works!
You can additionally file additional pull requests or bugs at my github repository (though if you DO have bugs, replying to this thread is much faster)