Introducing OverlapParams - New Spatial Query API

Absolutely amazing, I’ll have to use this in my safezone system

Next we could probably get support for multiple workspaces?

Could be great for keeping users in the same game but different sections of the map.

5 Likes

Yes.

local function IsBoxEmpty(cframe, size)
	local params = OverlapParams.new()
	local parts
	
	params.MaxParts = 1
	parts = workspace:GetPartBoundsInBox(cframe, size, params)
	
	if #parts > 0 then
		return false
	else
		return true
	end
end
3 Likes

I think these niche cases could be developers that relied on GetTouchingParts returning a blank table when CanCollide off.

1 Like

There kinda already is in a way depending what you need them for: WorldModel | Roblox Creator Documentation

The documentation says “for a ViewportFrame” because that’s almost always what they’re used for, but they basically are a full Workspace of their own, which you can use for stuff like doing region queries / raycasts against secondary world that exists in ServerStorage or something like that.

17 Likes

Awesome change! It seems much easier than having to use Region3s.

Are these more performant than Region3 though? Just a question.

4 Likes

It’s just that some might still want to use it for convenience, it can be handy to use within Touched event callbacks for pars and you don’t know what WorldRoot they are in. There are no plans to replace/change it any time soon though.

Should be pretty much the same performance wise. GetPartsInPart can just simplify things as you do not need to worry about the collision properties of the Part.

CFrame defines the center of the box, and orientation is taken into account. (updating post to clarify this)

It sure is :grinning_face_with_smiling_eyes:

I think radius, but not by much. The bounds queries do not perform any narrow phase, even on meshes. They only account for the bounding box of the part.

I haven’t checked tbh :sweat_smile:. These methods are using the new optimized collision detection system exclusively. Region3 checks weren’t before, and now they do (everything is). If I get the time I could test and report a bunch of benchmarks, but also anyone could do that now :wink:

47 Likes

Thanks a lot, this is gonna be really useful for my placement system. Is there any performance difference between :GetTouchingParts() and :GetPartsInPart()? I assume its faster.

2 Likes

Typo: FilterDescendantsInstance
Should be FilterDescendantsInstances

3 Likes

What should we use instead of that function?

1 Like

#workspace:GetPartBoundsInBox( cframe, size, op ) == 0

tip: you can also set OverlapParams.MaxParts to 1, so the function early outs as soon as a single part is found.

11 Likes

Oh my god this is soo goos I love it. It will really change a lot, and help me out :slight_smile:

Thanks guys

1 Like

Will these new region3 functions have any performance benefits over the old ones?

2 Likes

I noticed a spelling error in “Workspace” you had put “Worksapce”

2 Likes

It’s only baseparts, so no. Zone plus is still still great tool!

3 Likes

Yess! Now I can hopefully continue working on my guitar hero Roblox remake!

2 Likes

Will we be getting a boxcasting and spherecasting implementation next? Or will line-of-sight checks fall to developers?

5 Likes

I swear everytime I am in the middle of developing a system using my own method you guys release a beautiful alternative and I have to go in and change what I made the same day.

Brilliant! Thank you for this!

4 Likes

In my game, monsters are placed in a specific directory. If the returned result can be limited to the children in the specified directory with type of “Model”, that will be more better. I will not need to traverse which part is that monster.
When there is a limit on the number, it would be even better if we can choose to filter by distance

3 Likes

this is cool but still please dont remove findpartsinregion3 as a lot of scripters use it. (ofc they can update it) but some games have very lively communities while still not receiving updates.

2 Likes

This is deprecation, not removal. It probably won’t be removed for a long time due to the amount of code that relies on it.

4 Likes