generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Region3 not Finding Parts

Previous Thread :: Next Thread 
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 10:38 AM
Hello, I seem to be having an error in which a region3 is created perfectly fine, yet no parts are in the region3, even though there is a part in the region3.
This is my code.
region3create just creates a region3 with certain coordinates, and that works.

function findNodes()
local region = region3create()
print(region.Size)
local children = game.Workspace:FindPartsInRegion3(region,nil,100)
print(#children)
for _,v in pairs(children) do
print(v.Name)
end
end
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 11:22 AM
bump
Report Abuse
Valenthian is not online. Valenthian
Joined: 01 Oct 2013
Total Posts: 590
22 Aug 2014 11:37 AM
I really haven't worked with region3 yet so this comment might be dumb, but aren't you supposed to define the position somewhere?
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 11:45 AM
I already did.
The region3 is created fine, it's just the FindPartsInRegion3 function doesn't seem to work.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 11:48 AM
So the output successfully prints the size of the region? What's in the region3create() function? Are you sure you have to coordinates correct so that there are actually parts in the region?
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 11:56 AM
This is the region3create function:

function region3create()
Torso = script.Parent:FindFirstChild("Torso")
local bottomLeft = Torso.CFrame*CFrame.new(50,-30,50)
local topRight = Torso.CFrame*CFrame.new(-50,30,-50)
local bottom_Left = bottomLeft.p
local top_Right = topRight.p
region = Region3.new(bottom_Left,top_Right)
print("Region3 Created at ("..bottomLeft.X..","..bottomLeft.Y..","..bottomLeft.Z..") and ("..topRight.X..","..topRight.Y..","..topRight.Z..")")
return region
end

It works correctly, I teleported to both corners of the region3 to check, and there are definitely parts in the region.
Yes, the output is able to print the size of the region.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 12:03 PM
Instead of doing:
local bottomLeft = Torso.CFrame*CFrame.new(50,-30,50)
local topRight = Torso.CFrame*CFrame.new(-50,30,-50)

You could do:
local bottomLeft = Torso.CFrame + Vector3.new(50,-30,50)
local topRight = Torso.CFrame + Vector3.new(-50,30,-50)

Anyway, if you look at the wiki page here:
http://wiki.roblox.com/index.php/Region3

it suggests that the second point's XYZ values should always be larger than the first's. In the function you provided if we describe the points relative to the torso, the first point is at (50, -30, 50) and the second point is at (-50, 30, -50), therefore breaking the rule that the second point's XYZ values must be larger than the first's.

I think you just need to flip it? I haven't properly worked out the math in my head, but Region3s do not rotate so you'll have to generate it just based on two points.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 12:04 PM
flip the X and Z values I mean. The Y values are already in order.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 12:10 PM
Yea, I think if you just use:

local bottomLeft = Torso.CFrame*CFrame.new(-50,-30,-50)
local topRight = Torso.CFrame*CFrame.new(50,30,50)

it should work.
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 12:19 PM
That doesn't seem to work :/
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 12:32 PM
bump.
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 01:01 PM
bump
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 09:07 PM
I'm almost certain that your problem is what I said, unless Roblox made it the constructor for a Region3 negative-area proof. Find 2 points that'll construct the box that encloses your part, I can pretty much guarantee that if FindPartsInRegion3() isn't finding the parts, then your region is wrong or there are no parts.

In your region3create() function, the print statement at the end successfully prints right?

You can make placeholder bricks and change their position to the points you define to get a visual, but make sure the XYZ values of the first point are all less than the XYZ values of the second point respectively.
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 09:27 PM
I already used placeholder bricks, and that's how I knew for sure that there were bricks in the area defined by the Region3.
In my region3create() function, yes, the ending print statement prints.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 09:29 PM
okay, what are the points you're using?
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 09:31 PM
Here is my code for region3create() with the placeholders:

function region3create()
Torso = script.Parent:FindFirstChild("Torso")
local bottomLeft = Torso.CFrame*CFrame.new(-50,0,-50)
local topRight = Torso.CFrame*CFrame.new(50,0,50)
local bottom_Left = bottomLeft.p
local top_Right = topRight.p
region = Region3.new(bottom_Left,top_Right)
print("Region3 Created at ("..bottomLeft.X..","..bottomLeft.Y..","..bottomLeft.Z..") and ("..topRight.X..","..topRight.Y..","..topRight.Z..")")
part1 = Instance.new("Part")
part2 = Instance.new("Part")
part1.Anchored = true
part2.Anchored = true
part1.Position = bottom_Left
part2.Position = top_Right
part1.Name = "BottomLeft"
part2.Name = "TopRight"
part1.Parent = script
part2.Parent = script
return region

end
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 09:32 PM
It's using the points that were used to create the Region3; bottomLeft and topRight
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 09:42 PM
your Y values for both points are zero, effectively only checking if anything intersects the plane that is at torso height and is a square with length 100 centered at the torso.

Are you certain that there are parts that hit this plane?
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 09:47 PM
I changed them back to -30 and 30, respectively, and it still doesn't work, even though there are parts in that area.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 09:48 PM
try making the box much larger than it's supposed to be and see if it detects anything then.
ex. bottomLeft = (-1000, -1000, -1000), topRight = (1000, 1000, 1000)

Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 09:50 PM
I changed the region3 to those values.
Not a single part found.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 09:51 PM
also, since you're making the box based on the torso, it means it's dynamic depending on where the torso is.
Is what you're checking with the placeholder bricks lining up with the spot where the torso supposedly is when you checked the area with placeholders?
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 09:52 PM
try making a region that is static and not dependent on the torso's CFrame and see if it detects it then.
Report Abuse
sayhisam1 is not online. sayhisam1
Joined: 25 Nov 2009
Total Posts: 2092
22 Aug 2014 09:52 PM
Yes, it is lining up.
I am starting to think it is a roblox issue.
Report Abuse
oatsssss is not online. oatsssss
Joined: 31 Jul 2014
Total Posts: 170
22 Aug 2014 09:53 PM
If it is, it must be triggered by something because on its own, the FindPartsInRegion is working for me when I test it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image