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: Finding the height of a pile of random bricks

Previous Thread :: Next Thread 
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
08 Jul 2014 07:00 PM
Like, the hight in studs.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
08 Jul 2014 07:03 PM
store said "random bricks" in a model

local model = Workspace.Model
local max = 0

for _,v in next,model:getChildren() do
if (v:IsA('Part')) then
max = v.Position.y > max and v.Position.y or max
end
end

print('Height is '..max)
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
08 Jul 2014 07:05 PM
well actually that assumes that the pile is rooted at 0
this should work better:

local model = Workspace.Model
local max = 0
local min = 0

for _,v in next,model:getChildren() do
if (v:IsA('Part')) then
max = v.Position.y > max and v.Position.y or max
min = v.Position.y < min and v.Position.y or min
end
end

local height = max - min
print('Height is '..height)
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
08 Jul 2014 07:06 PM
Also, these bricks will all have a random rotation... Will this above example still work if this is the case? I should have said this sooner, I'm sorry :\
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
08 Jul 2014 07:17 PM
um, it will work to a certain extent.
let's say this is what your pile of bricks looks like:
im . gur dot com slash zrbxg3d.png

notice the top and bottom bricks have red origins, even though since the top brick is rotated 90 degrees it will affect the height of the pile
well, this is what the script will detect the height to be:

im . gur dot com slash XLbq8Gk.png

i can fix if needed
Report Abuse
tinarg is not online. tinarg
Joined: 18 Jun 2010
Total Posts: 4925
08 Jul 2014 07:22 PM
It's okay. This system is FAAAR more accurate than my old one. If it's off by a few studs, it won't hurt a thing.

Actually, this isn't calculating a pile of bricks, but a ball that can roll up bricks to increase its size. I needed to determine a rough height to see if a brick it touched was small enough to pick up. (If you have ANY clue what a katamari is, this is what I'm making here).
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
08 Jul 2014 07:26 PM
well i googled katamari and i still have no clue what it is
but it sounds cool anyway
gl
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
08 Jul 2014 07:33 PM
omg i love that game. played it when I was a lot younger.

you can put an invisible brick as a hitbox for the model and use that brick's size.Y as a way to determine it.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
08 Jul 2014 07:34 PM
how does one hitbox
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
08 Jul 2014 07:37 PM
Step 1: insert a brick
Step 2: put the brick in the desired model
Step 3: stretch the brick to best fit the size of the model
Step 4: Make it invisible

You have a hitbox.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
08 Jul 2014 07:39 PM
you don't even have to use a part. .-.
look at what i was doing, it's more efficient
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
08 Jul 2014 07:41 PM
I was just suggesting that a building alternative might be easier if the variety of models wasn't so big.
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