A question regarding Region3s

Are the region3’s CFrame & size read-only? Or can they be edited through any means? Let’s say for instance I’m working on an attack that requires the region3 to keep being positioned relative to a rig’s position in contrast to a point, so basically a beam. Is there a better way of doing this instead of instantiating multiple region3’s with each beam, or can I constantly update one region3 to keep updating its own position? I ask this because region3’s are really expensive to instantiate… what’s a better way of doing this if I’m not allowed to edit its properties?

Here’s a visual example of what I mean:

Per beam, here’s what I’ve got going on per each loop, which is very costly, while it does work, I was wondering if there was a better method about going about this.

local Hitbox = RotatedRegion3.new(Beam.CFrame, Beam.Size);
local PartsInRegion = Hitbox:FindPartsInRegion3WithIgnoreList(Rig:GetDescendants(), 999);

for __, Part in pairs(PartsInRegion) do
    local Hitting_Character = Part:FindFirstAncestorOfClass("Model");
    if (Hitting_Character) and (Hitting_Character:FindFirstChild("Humanoid")) then
        local Humanoid = Hitting_Character.Humanoid;

Thanks in advance!! :grinning_face_with_smiling_eyes:

Can I treat Region3’s properties like normal instances, such as parts? Like this?

local Region3 = RotatedRegion3.new(Beam.CFrame, Beam.Size);
RotatedRegion3.CFrame = Set_CFrame;
RotatedRegion3.Size = Set_Size;
1 Like

I was also messing around with Region3s and tried moving their CFrame, but it said “could not cast blah blah blah”, meaning you can’t manipulate them.

Also, before asking questions on the DevForum, trying looking on the DeveloperHub (Roblox Creator Documentation) or testing it out for your self for answers to questions like this.

1 Like

I see, my bad. I’m a little new here. Thank you! :happy1:

I checked ROBLOX’s official API, and I didn’t really find anything other than that region3’s have properties, but it never stated whether they’re able to be manipulated or not.

That leads me to my other question:
What’s a better way of going about this, then without instantiating multiple Region3’s at once? Because it’s super costly.

1 Like

I’m still struggling to find a more efficient way to go about my problem. Could anybody perhaps help me…? Thank you!

You could make a whole part that would be the same size as the beam. Make it transparent, and check for touches on the part. Don’t forget to add a cooldown so no stack overflow.

You’re recommending I use .Touched?

…Nah, I’ve had my fair share of that connection, it doesn’t suit me well, nor is it 100% accurate. I might just look into raycasting for now.

The problem with raycasting in this scenario is that you have to do mutliple raycasts each frame for every x & y, making it quite laggy. Raycasting is better used if its for bullets/projectiles.

For accuracy (ironic to what you said), you want to use .Touched instead because it covers all of the area of the beam and doesn’t kill performance.

I forgot to update this, but I figured it out completely.

ROBLOX just recently created a completely new function to their API, New Spatial Query API. Check it out.