Current Version: V.4.01 Stable (09/21/2021)
Notice
I will be releasing a new module with new features, including Shapecasting in the near future. Stay tuned! More information:
Raycast Hitbox 4.01: For all your melee needs! - #1133 by TeamSwordphin
Upgrading from 3.xx to 4.0
Please note that V4 is not backwards compatible with V3. There are a few API changes that were introduced in V4 to better suit modern code etiquette. Here are the changes you need to know if you want to make your code compliant with V4:
Raycast Hitbox 4.01: For all your melee needs! - #597 by TeamSwordphin
Notable Features
- 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 automated individual part hit tracking, humanoid only, or even unfiltered hits!
- Hitbox distinction (for example, smash bros tippers!)
- Hitbox Time Scheduler, set and forget; let the module turn off the hitbox for you!
- Supports Mesh Deformation!
- No credits necessary and full help support available!
Introduction
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!
OR
Example Place
Direct download
RaycastHitboxShowcaseV4.rbxl (107.4 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.
https://gfycat.com/welcomeglitteringkillifish
https://gfycat.com/fairsecondaryafricangoldencat
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.
https://gfycat.com/enchantingdecentbeagle
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.
Limitations
- 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. The module supports different detection modes, so if you dislike this functionality, there is a way to change it.
- Wide objects requires a lot of attachments to be working correctly
Update Log
Current Version V.4.01 Stable (09/21/2021)
- Fixed inaccuracy issues. Credits go to @bagwan12345
- GoodSignal implementation
- SignalTypes
- More Information: Raycast Hitbox 4.01: For all your melee needs! - #743 by TeamSwordphin
â
Previous Versions & Downloads
V.4.0 Stable (07/02/2021)
- Rewrote module to more legible and with more common coding etiquette
- Typechecking
- Minor hit detection optimizations
- Significantly more optimized debug visualizer rays
- Different Detection Modes
- Mesh Deformation support
- Debug Visualizer rays no longer give false positives to the hit detection
- Debug Visualizer rays switched to LineHandleAdornments
- Module is now Rojo-compliant at Github
- More Information: Raycast Hitbox 4.01: For all your melee needs! - #597 by TeamSwordphin
V.3.3 Stable (02/25/2021)
- NEW Hitbox:HitStart(seconds) custom scheduler. If optionally given, will automatically turn off the hitbox after the given seconds has elapsed. Uses os.clock for maximum accuracy.
- More details: Raycast Hitbox 4.01: For all your melee needs! - #442 by TeamSwordphin
- RaycastHitboxV3.rbxm (9.2 KB)
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)
1.0 BETA
- 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)
My other modules:
Inverse Kinematics and Procedural Animation
Part Pooling