Rotated Region 3 Module

Right you are!

A month ago or so I pushed a change removing something I thought I didn’t need. Turns out it was necessary and I now remeber why (had to do with the different shapes)!

I’ve gone and fixed that up. Sorry for the difficulty!

3 Likes

woudlent it be easyer to just have some points with magnitude and simple logic
so like say, has to be within magnitude of this point and this point, and not in this point.

I don’t know if I’m setting this up incorrectly, but I just tried again and I got the same error at line 88, attempt to index a nil value. :confused:

Did you update the module?

Line 88 doesn’t have the same code that it used to.

2 Likes

This is actually bizarre, even after deleting and retaking the model in your OP, the line of code at 88 still looks the same, indexing set.

:confused:

It is bizzare. Line 88 has nothing to do with indexing set anymore. It’s a completely different function. I reinserted from the OP again just to make sure:

RobloxStudioBeta_2020-05-01_21-27-28

Line 88 used to be where line 101 is currently. I’m just as confused as you are. Can you open the module and confirm the existence of the get corners function?

1 Like

Bingo. Turns out I needed to restart Studio or open up a new place for it to update marketplace assets apparently.

May or may not be an engine bug, but it’s the updated version now.

2 Likes

Yeah, I’ve been having that same problem of updating a model, inserting it again, and studio inserting the old version. Studio will only insert the new version in a new studio window.

3 Likes

How do i will remove region? pls tell

One way is to create your own :Destroy() Function for the custom object like in the wiki:

However, since I believe the rotated region3 object has no events that you can just set the table to nil like so and wait for garbage collection:

local testRegion = RotatedRegion3.FromPart(sphere)
testRegion = nil

Please correct me if I’m wrong.

@EgoMoose

Hi, I was attempting to use your module for one of my moves, but I was struggling to get it to work properly. Here is the code

local RoadRollerHitbox = REGION3_HITBOX.Block(roadrollermod:GetModelCFrame() ,roadrollermod:GetModelSize())

local partsInRegion = workspace:FindPartsInRegion3(RoadRollerHitbox,50)
		for i , v in pairs(partsInRegion) do
			print("debugprint")
			if v.Parent  and v.Parent:FindFirstChildOfClass("Humanoid") and v.Parent:FindFirstChildOfClass("Humanoid").Health > 0 and (v.Parent:FindFirstChild("Torso")) then
				if #AlreadyDamaged > 0 and table.find(AlreadyDamaged, v.Parent) then print("Prevents it from damaging twice")
					
				else
					
				   local hum = v.Parent:FindFirstChildOfClass("Humanoid")
					table.insert(AlreadyDamaged, hum.Parent)
					
					damageevent:FireServer(hum, chr["Right Arm"].CFrame, 3, 0.4, rot.CFrame.lookVector * 0, "rbxassetid://241837157", 0.5, Color3.fromRGB(255, 0, 0), "rbxassetid://542443306", math.random(9, 11) / 10, math.random(9, 11) / 35, game.Players.LocalPlayer.PlayerGui.Blood.BloodVal.Value) --Handles damage.
					knockevent:FireServer(hum) --Stuns player.
					--end
				end
			end
		end

I don’t work with Region 3 often so I believe I messed something up :sweat_smile:.
This error comes up when I try to use the code above: “Unable to cast Dictionary to Region3”. All help is appreciated! :smile:

Hmm, you are are creating the region 3 object as:

local RoadRollerHitbox = REGION3_HITBOX.Block(--stuff)

And I believe you need to use RotatedRegion3 Object methods to find the parts within the region instead of mixing it up with the Roblox’s workspace object methods workspace:FindPartsInRegion3 methods so you should do this:

local partsInRegion  = RoadRollerHitbox:FindPartsInRegion3(Instance ignore, Integer maxParts)

Substitute the ignore and max parts according to the documentation and see if it works.

returns array of parts in the RotatedRegion3 object
will return a maximum number of parts in array [maxParts] the default is 20
parts that either are descendants of or actually are the [ignore] instance will be ignored

Will this work, or am I still doing it wrong?

local partsInRegion = RoadRollerHitbox:FindPartsInRegion3(chr:GetChildren(), math.huge)

Bruh this is so good and even easier to use than normal Region3

1 Like

I think it was useful for its time, but it seems soon enough we’ll have something built in-engine to replace this! :partying_face:

18 Likes

I don’t know what I did wrong here, but this (server) script gets me a Argument 1 missing or nil on line 210 on the RR3 API module, I’m not sure if I did something wrong or if it’s a bug.
Here’s the code:

local rotatedRegion = require(game:GetService("ServerStorage").Modules.RotatedRegion3)

local config = script.Parent.Configuration

local objectHealth = config.ObjectHealth
local objectMaxHealth = config.ObjectMaxHealth
local flammable = config.Flammable
local onFire = config.OnFire
local ignoreBullets = config.IgnoreBullets

local part = script.Parent

--local a = Vector3.new(part.Position.X-part.Size.X-0.1, part.Position.Y-part.Size.Y-0.1, part.Position.Z-part.Size.Z-0.1)
--local b = Vector3.new(part.Position.X+part.Size.X+0.1, part.Position.Y+part.Size.Y+0.1, part.Position.Z+part.Size.Z+0.1)
local region = rotatedRegion.Block(part.CFrame, part.Size)

local shards = math.floor(part.Size.X * part.Size.Y * part.Size.Z + 0.5)*8

local function updateRegion()
	--a = Vector3.new(part.Position.X-part.Size.X, part.Position.Y-part.Size.Y, part.Position.Z-part.Size.Z)
	--b = Vector3.new(part.Position.X+part.Size.X, part.Position.Y+part.Size.Y, part.Position.Z+part.Size.Z)
	region = rotatedRegion.Block(part.CFrame, part.Size)
end

------------------------------------------------------------------------

while objectHealth.Value > 0 do
	wait()
	updateRegion()
	local touchingParts = rotatedRegion:FindPartsInRegion3(part, 100)
	for i, _part in pairs(touchingParts) do
		local child = touchingParts[i]
		if child:FindFirstChild("Configuration") then
			print("Config")
			if child:FindFirstChild("Configuration"):FindFirstChild("ObjectDamageValue") then
				print("ObjectDamageValue")
				objectHealth.Value -= child:FindFirstChild("Configuration"):FindFirstChild("ObjectDamageValue").Value
				
				if objectHealth.Value <= 0 then
					part.GlassShards:Emit(shards)
					part.GlassShardsSmall:Emit(shards)
					part.CanCollide = false
					part.Transparency = 1
					part.Shatter:Play()
					break
				end
			end
		end
	end
end

Never used this module but I think the issue is that you are trying to call :FindPartsInRegion3 on the module itself instead of the Region.

local touchingParts = rotatedRegion:FindPartsInRegion3(part, 100)

to

local touchingParts = region:FindPartsInRegion3(part, 100)
1 Like

Very very Clean! i love this module, thank you!

Is there a way to find the position the region3 intersected at?

Omg this is so easy to use, tysm.