World Point Proximity Check

Hey nerds! Fellow nerd in need of assistance!

I’m facing a situation that requires me to detect if a part is within a certain radius at a point in the world.

For example, if I have a point of Vector3(5, 5, 5). I want to check if a part is intersecting within a certain radius. Lets say the radius is 5. So any parts within 5 Studs from our point is counted as intersecting.

Should I go about using a Region3 with a bunch of ignores to achieve this? Or should I create a part at the end point and fire GetTouchingParts()?

This is mostly aimed towards efficiency. Thanks!


I think region3 would be best, although you wouldnt be able to get a radius of five because region3s are not circular they are rectangular so you will get a square region of 5,5,5 that will check for parts. I would recommend using a whitelist if you know exactly which group of parts you will be searching for it will decrease computation time.

If I have understood your post correctly, you have 2 options:

Use DistanceFromPlayer API reference here
Or .magnitude API reference here

And use RunService.Heartbeat to constantly update the distance value. API reference here

Magnitude wouldnt work in all cases. When you measure distance you usually measure it from the center of the part, so if the part is large enough so that only an edge of it would get into range of the 5 stud radius it wouldn’t be considered an intersection

1 Like

While it wouldn’t work in all cases, OP says he has a Vector3 thus no mid point and the HumanoidRootPart size is negligible or at least be able to increase the radius size to compensate. Unlike a Region3 (unless using this module) it is a cuboid, meaning there is no radius with some areas futher away from the point than preferable.