ForLoop parent to previous

So I have a loop function that runs 4 times. Each time it runs it creates a box incrementally moving it along the x axis. How could I make the loop link to the box previously created in the loop?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JokerMartini's picture

Answer!


(
local parentBone = undefined
mybox = box length:10 width:10 height:10 wirecolor:blue --new box

for i = 0 to 5 do --repeat five times, for each iteration do:
(
box_copy = copy mybox --create a copy of the original box
box_copy.pos = [i*20, 0, 0] --place it i*20 units along x
if parentBone != undefined then
(
print "Link"
box_copy.parent = parentBone
)
parentBone = box_copy
)--end of the for loop
)

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.