Introducing OverlapParams - New Spatial Query API

It was returning terrain. Now it’s not. You are right.

1 Like

@Razorter @EtiTheSpirit @GMaxZet

None of this API includes terrain right now, which matches the old Region3 API behavior. (However, Part:GetTouchingParts will include terrain)

We could add this though, probably via an OverlapParams.IncludeTerrain parameter?

16 Likes

I’m sure I had Terrain instance there. Must been a glitch.

It would be cool to have the ability to query the terrain using this API. Thank you, you rock!

1 Like

Terrain is technically a part so yes please. If it’s also possible, can you add IgnoreWater so it’s consistent with RaycastParams?

1 Like

I doesn’t say anywhere on the developer hub that the Region3 functions are deprecated.

Because they haven’t been marked as that yet, but trust me, if a Roblox Staff Member says that they’re deprecated then they’re deprecated.

I wonder if the first parameter (PartInstance part) of the third new function introduced (WorldRoot:GetPartsInPart) actually includes the MeshPart. If no, then this third new function is pointless since we can basically do it using the first new function :sweat_smile:

I’m sure it will work, if not then imagine the hitboxes people have to create with just squares and spheres. Ouch.

That means the third function is custom and free for all, sounds nice! :laughing: :smiling_face_with_three_hearts: :melon:

1 Like

If it doesn’t, im sure Zone+ is updated and/or updating their module with the latest query API for all to use :+1:

I can’t get it to work with MeshPart bones!
Is it because OverlapParams checks against part.Position and for bones should check for bone.WorldPosition (or bone. TransformedWorldCFrame.Position) ?

1 Like

I think this method needs a boolean version. Bool = IsPartInPart(PartA,PartB) If I want to ask if a certain part is simply overlapping another part. Such a function may be less intensive on game performance and a lot simpler to use.

That’s what I wanna know. Though, I did run GetPartBoundsInRadius in a fast loop and its an extreme resource hog (talking like >50% CPU usage). I find that looping through the parts and checking their distance with the good old (pos1 - pos2).Magnitude was less resource intensive, but I do understand why as it’s trying to factor in the bounds of a part rather than just a simple distance check from their positions.

Update on this: I did a test to see which is faster (Region3 vs BoundsInRadius).
These were my results (each was ran 10 times):


Region3

All times:
0.1491571000078693
0.13990179996471852
0.14120559999719262
0.13626439997460693
0.1535322000272572
0.1385526999947615
0.14146419998724014
0.16613239998696372
0.13969529996393248
0.1388802999863401

Average:
0.14447859998908824


BoundsInRadius

All times:
0.3513048999593593
0.3413050000090152
0.3363081999705173
0.3346049999818206
0.3367011999944225
0.3251165000256151
0.33610730001237243
0.32732949999626726
0.33658229996217415
0.33615290001034737

Average:
0.33615127999219113


As you can see, Region3 is still largely faster

These times have been cleared up by @kleptonaut

So your saying, that Region3, a recently deprecated thing is still faster than the new flashy OverlapParams?? Roblox can’t be that high to deprecate a system thats faster than the new one.

I mean, Region3 just takes the part positions in a square. PartBoundsInRadius takes into account the bounds of the part though. Of which is more expensive to calculate instead of just its position.

1 Like

I’ve never used BoundsInRadius for object detection yet, but id imagine it would be slower because its calculating a circle if I am correct. I use GetPartsInPart for hitbox collision checking

Calculating in a circle isn’t all that expensive. It’s just a simple distance check by subtracting the 2 positions and accessing the Magnitude property.

Like this:

local distance = (pos1 - pos2).Magnitude

Or if you want to be real technical:

local distance = math.sqrt((x1-x2)^2+(y1-y2)^2+(z1-z2)^2)

The real expensive part is it has to factor in part bounds, of which it has to get every corner and point of a parts bounds and check if it is overlapping in the radius.

ah thats true, I was calculating that with my placement system detection, however when i was using it theres no issues that are really worth looking into because its all ran on the client and verified on the server

I think a function for Vector3s should be added. The function will check if the vector3 is inside the region. I think this will be helpful for people who dont want to use parts.

2 Likes