So I’m pretty new with the RotatedRegion3 module stuff, I however, don’t know how to use it properly.
I’m currently trying to make a placement building system where buildings don’t collide eachothers.
I have tried to fix it plenty of times, but it kept returning me with:
“Unable to cast value to Objects”
This is the module I’m currently using.
Current code on attempting on using FindPartsInRegion3WithIgnoreList
local mouseRay = mouse.UnitRay
local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 1000)
local ignoreList = {clientStructure,char}
local hit, position = RotatedRegion3:FindPartsInRegion3WithIgnoreList(castRay, ignoreList)
Thanks in advance!
Now, I haven’t used the RotatedRegion3 module before, but I’m willing to bet that the FindPartsInRegion3WithIgnoreList takes a Region3 argument, not a Ray argument. Your code looks like a combination of raycast and region3 code, so I think you’re getting confused between the two.
Hello,
Well I have used the non module version, and it works. Here’s the code.
local mouseRay = mouse.UnitRay
local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 1000)
local ignoreList = {clientStructure,char}
local hit, position = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList)
But I wanna use the module version.
That’s what I thought, you’re mixing up raycasts and region3s.
This line is roblox API, and as the name of the function suggests, it requires a Ray argument.
With this line, you’re assuming that region3’s work the same as rays, but they don’t. You’re getting an error because you’re putting a Ray object inside of a Region3 argument. The FindPartsInRegion3 API, works differently. A ray can only intersect 1 part, but a region3 can intersect many, so it returns a list. (FindPartSInRegion3).
Since region3’s receive a list of parts inside that region, you will need to loop through that list to find what you need.
for index, part in pairs(workspace:FindPartsInRegion3(region)) do
print(part, "is positioned at", part.Position)
end
1 Like
Kind of strange, I did researches and most scripters input “Ray”. Strange but I’ll keep looking towards it.
Okay, I’ve tried using Region but that didn’t seem to work. I’m probably doing it wrong since I’m very bad at this.
local ignoreList = {clientStructure,char}
local min = clientStructure.Node.Position - (0.5 * clientStructure.Node.Size)
local max = clientStructure.Node.Position + (0.5 * clientStructure.Node.Size)
local region33 = Region3.new(min, max)
local hit, position = RotatedRegion3:FindPartsInRegion3WithIgnoreList(region33, castRay, ignoreList)
Any help would be appreciated…
Oh alright, I see what I did there. I thought both of those codes were the same thing. I apologize. I’ll mark your post as a solution now. 