tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
| |
|
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
|
  |
| 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
|
  |
| 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 |
|
|