Most efficient way of detecting a part in an area

I could just use the collider generated by Roblox but it is impossible to get the data so the only way is to do checks to get the “even more” approximated collider.

What problem did you have that led you to try this solution? Just trying to avoid an xy problem :slight_smile:

Regardless, is there a requirement for it to be real-time and constantly recomputed? In other words why is 0.075s too slow, can’t you compute the result once and store it?

I don’t think you’ll get much faster than what you have in-game. If you own these meshes you could pre-voxelize them in an outside program and export the data as a lua table or something.

I can but for bigger meshes recomputation will be needed as if a block hits a mountain then with the current check quality the entire block is going to be considered touching the mountain. I will still implement a system that only checks 3 axis as the hitpoints will be used to calculate the force applied so getting the ones opposed to the velocity is useless.

So, in my case the problem is more the real-time recomputation than the pre-computation.

Are you making a gun? A physics simulation? Something else? Sorry for pushing it’s just extremely helpful to know the “why” before solving the “what”

I’m making a destruction script and in order to make it more fun I tough it would be cool to have hitpoints for things like simple block fracture or car mesh deformation and also for fighting so maybe a katana and things like that. As I said, I don’t need 100% accuracy but sometime to get to the level where it wouldn’t obviously be innacurate you need to recompute the hitpoints.

Before switching to this method, I had a script that would use raycasting for things like this. The accuracy is better and it takes a lot less time ~ 0.026s for 3 sides compared to 0.12s with the GetPartsInPart method.


This was the result for only 3 sides.