My question: Rotating a
Region3
I am making a placement system for a game and need collision. I am trying to use Region3s but when I rotate my model the region does not. I do not know if rotating Region3s is possible. Anyway here is my code for the Region3.NOTE: everything is inside of a LocalScript in a gui in StarterGui.
This is in the function that starts placement (Sets properties)
Code samples
regionPart1 = (model.PrimaryPart.Position - (model.PrimaryPart.Size / 2))
regionPart2 = (model.PrimaryPart.Position + (model.PrimaryPart.Size / 2))
while true do -- So it updates the region
region = Region3.new(
regionPart1, regionPart2
)
wait(0, 1)
end
Here is my collision detection code:
-- Detecting collision
-- This is in the movement function so it gets called every time the mouse moves
regionPart1 = (model.PrimaryPart.Position - (model.PrimaryPart.Size / 2)) -- Update
regionPart2 = (model.PrimaryPart.Position + (model.PrimaryPart.Size / 2))
for i, v in pairs(modelInRegion) do
if v.Parent:FindFirstChild("Primary") ~= nil then
ModelsFound[v.Parent.Primary.Name] = v.Parent.Primary
isColliding = true
else
isColliding = false
end
end
for index, value in pairs(ModelsFound) do
spawn(function()
isColliding = true
end)
end
Failed solution
I have tried updating the CFrame of the region when the model rotates like this:
region.CFrame = CFrame.new(regionPart1, regionPart2) * CFrame.Angles(0, math.rad(Rot), 0)
In the output it said CFrame could not be set.
End
If there is anyway to rotate a Region3 by 90 degrees then let me know (Not asking for a whole script just either the place to find the answer or a explanation of how it works)!
Thanks for helping!
(Also if there is a better way to detect collision then that would also be helpful)

1 comment
All the code is in a local script