Hello developers,
I am working on a few functions that should spawn some object (function parameter) at a random position within a Region3 or part.
Now the problem is that within that Region3 there can be other buildings, which I’d like to exclude from the region so the object won’t spawn there (so the random position will not be set within that building).
I’ve heard that WorldRoot:FindPartsInRegion3 can take up lots of resources.
I’ve looked on the DevForum for ways to make this, such as:
- non-square region
- “Region with a hole”
- how to exclude things from region3
(and of course, I included Roblox keywords)
But couldn’t find anything related.
Illustration of my problem:
Idea for an alternative
I’ve thought of checking whether the random position is in the part, and if it is, get another position.
But the problem is that to check if it is in the part I’ll have to use FindPartsInRegion3 for the part’s box right? And there are chances for it to spawn in the excluded area again, which will slowly eat up the memory and performance…
Is it possible? Is there a way to achieve this or a better alternative?