How to do hit detection for a fast and large projectile

Currently I have a big projectile lets say about 5x5x5 studs. It moves at 1200 studs per second using CFrame updates every render stepped. How would I do hit detection for this.

Just cast a ray where its direction starts from the gun and to the mouse.Hit.p.

actually for the smaller projectile, I would ray cast every time the position update, the bullet doesn’t have instant velocity. The issue is the player grazing the sides of the large bullet would not register with raycast.

Wait, how does your projectile works?

So when the bullet is created, it makes inside workspace. Every render stepped, it calculates the new position of the bullet. Then it raycasts from the current position of the bullet to the position of the new location. if it doesn’t detect anything, the bullet is teleported to the new location. Otherwise it hits the player. This works really well for small projectiles but anything large doesn’t work so well.

Why would you originate the Ray from the bullet, NOT the gun?

This allows for parabolic trajectories and also the bullets do not have instantaneous speed. doing one raycast means the bullet travels instantly,The first raycast origin is from the gun, but the rest is from the bullet.

I do not understand this. What are you talking about.

Parabolic trajectories make the bullet move in an arc instead of a straight line so there is bullet drop. If I raycast from the gun to the mouse position, this won’t go well since all shots will hit the other player instantly this will make sniping very very deadly. The issue I have isn’t the raycast, I got that to work, the issue is a large projectile lets make it say 10X10X10. Using raycast, the player has to be hit by the center of this massive bullet, I want to figure out a way to hit the player even if they are touching the side of the bullet.

1 Like

Maybe add a Touched event for the bullet parts.

Very fast bullets do not handle touch that well.

1 Like

Could you show a video of how they work if you can.

1 Like

This probably isn’t the best answer, but maybe a Region3?
You can make the Region3 larger than the player, and then calculate the distance between the bullet and the player when it gets detected.

Roblox currently has pretty bad .Touched detection for really fast moving projectiles, although they’re working on it as we speak. There are a couple good libraries you can use to remedy this temporarily, though:

While it’s advertised as being used for melee, the hitbox method is really good if you’re looking to get something returned if it hits it while your projectile is moving at 1200 studs per second. Very performant as well.

Secondly, if you don’t want to use the Raycast Hitbox library, you could also use RotatedRegion3s, as they’re pretty simple to set up:

I’m not extremely familiar with all of the functions of RotatedRegion3, but my only caution for you if you decide to use this is performance.

As always, you want to limit yourself on doing anything intense unless you absolutely have to - especially if you’re doing hit detection from the server. And creating a large Region3 (or subsets of Region3s to account for rotation?) with multiple FindPartsInRegion3 calls as well as accounting for potential numbers of parts (math.huge is a no-no) in a Region could be dangerous. Especially when it comes to creating it on every Heartbeat of the game.

Both methods account for your ‘player-grazing the part’ scenario. A 5, 5, 5 BasePart shouldn’t be that bad. Good luck on getting things to work on your end!


thanks looks like an interesting solution. Using multiple raycasts for a single bullet seems like a good idea, I might use region3 first unless that takes up too much memory thanks !

If you don’t monde me asking how you use multiple rays without over damaging a player since there is multiple rays being fired?

sorry for the late reply
so here is how my system works. When you fire the bullet, it has the object, start time, start position, and ignore table. Also have the variable for the last time the bullet was moved Then it runs every heartbeat. After every heart beat it subtracts the last shot time and start time to get the time changed for that and also the new position. A ray is then casted from the current position to the new position. If it hits the player it stops moving the bullet.
If you are asking about the sword, its not generating say 5 rays at the same time, it casts 5 very quickly every time it updates so you can just stop it if it hits something.

1 Like

Did you multiply the part’s size with the ray?

No, just put attachments on it to approximate the hitbox.