Hitbox for Fast Moving Objects

as you can read in the title, Im making a football game and I used MuchachoHitbox Module to Detect when the ball is touching the Player Hitbox, the issue is that its not working when the ball is going fast (when the goalkeeper want to catch it ) which is annoying

Thats why im thinking of making my own Custom Hitbox for my game so what should i use to make a good hitbox that detect Fast moving Objects ? I don’t want to use a touched Event since its bad for this

I’d refer you to this:

1 Like

I think this is good for melee fights , don’t know if its useful for a football game hitbox

1 Like

Melee just means it was built for melee but you can use it for other stuff like footballs moving fast

1 Like

And instead of Raycasting you can now use Shapecasting instead of a small Ray:
Introducing Shapecasts

1 Like

This look interesting, I will take a look at it Thanks !


You could try checking out how FastCast handles projectiles!
By scrolling down under the ActiveCast module, you can see something of a for loop that handles the projectile’s raycast. By separating each distance travelled from the last frame(s) into segments.

For example, the ball travelled about 15 studs away from the origin, now, you get to calculate the segments by doing math.floor(distanceTravelled / segmentSize) where segmentSize is how long each segment should be. Now that we have our first value of 15, divide it by 3, we get about 5 segments! In a for loop, you have to iterate from the index of 1 up to the amount of segments are there.
Now here’s the tricky part, because you want these segments to check if it hit something without crashing Roblox, you have to add in a debounce!
Lastly, all you have to do to detect for collisions is by using either workspace:GetPartsBoundInBox() or workspace:Spherecast()
Here’s an example:

local distance = 15
local segmentSize = 3
local size = math.floor(distance / segmentSize)
if not activelyCheckingCollisions then
  activelyCheckingCollisions = true
  for i = 1, size do
    local result = someCollisionDetectionFunction() -- workspace:Spherecast() or workspace:GetPartsBoundInBox() / workspace:GetPartsBoundInRadius()
    if result ~= nil then -- if result returns a table of instances: `result ~= nil and #result > 0 `
      local player
  activelyCheckingCollisions = false

Hope this helps!

1 Like