Notifications
Clear all

[Closed] Question about moveKeys

Hi all …
i created wave like animation by copying one animated box (image attached) and i offset the keys by using a code from bobo’s CG Academy training :

theOffset = 0
For o in $Box* do moveKeys o.height.controller (theOffset +=1)

but how can decide the direction of the animation (it follows the copying order)

Thanks in advance

2 Replies

You can control the ‘direction’ by controlling how you loop over the Box objects.

Right now you’re using “for o in $Box*” which will collect all of the objects with names starting with “Box” in the order they were created. To reverse the direction, all you have to do is loop over that collection in reverse order


-- let's store the collection
myObjects = for o in $Box* collect ( o )

 theOffset = 0
 
-- loop over it forwards
for o in myObjects do ( moveKeys o.height.controller (theOffset +=1) )

-- which can alternatively be written as...
-- (bit slower, so don't use if you don't need it this way)
for i = 1 to myObjects.count do ( 
  o = myObjects[i]
  moveKeys o.height.controller (theOffset +=1)
)

-- loop over it backwards
for i = myObjects.count to 1 by -1 do ( 
  o = myObjects[i]
   moveKeys o.height.controller (theOffset +=1)
)

thanks a lot redvelvet this way explained many things to me … but what i mean is if i want it to stars from a specific object … what can i do