[Closed] How to animate cubes orbiting joining and separating from a sphere?
Hi,
I’m trying to create a visual where cubes orbit a sphere joining and separating like a a big jigsaw puzzle. I really have no idea where to start with it and was hoping there would be a script out there to achieve it.
See this image for what i want to do.
Thanks,
eb_dev
Do they linearly fly in, over their local Z axis?
If so just animate all the boxes flying in the same time and then random offset the animation.
for o in selection do insertTime o.transform.controller -10 (random -50f 50f)
The random part is the min and max timeoffset
-10 is where to start putting in time, keep this below the actual keyframes or it will scale the animation.
Lookup insertTime in the helpfile.
-Johan
Hi JHN, thanks for your reply. The cubes should be rotating around the sphere in a orbiting fashion, occasionally slotting into the sphere and then coming out again and continuing their orbit.
Have you got some code which would do the moving of the cubes?
the image was interesting so quickly wrote this try it out and reply.
Just execute this script in a empty scene. with animation range of 300…
sph = (converttoPoly (sphere radius:100 segs:32))
for p = polyop.getNumFaces sph to 1 by -1 do polyOp.detachFaces sph #{p} delete:true asNode:true
delete sph
select objects
sel = selection as array
for i in sel do
(
RotValInv = inverse ((matrixFromNormal (polyop.getFaceNormal i 1)*i.transform) as quat)
i.pivot = i.center
in coordsys local i.rotation*=RotValInv
i.objectoffsetrot*=RotValInv
i.objectoffsetpos*=RotValInv
addmodifier i (shell innerAmount:10)
with animate on
(
at time 150 in coordsys local i.pos.z += 150
at time 300 in coordsys local i.pos.z -= 150
)
)
$.pivot = [0,0,0]
with animate on
(
at time 150 rotate $ (angleaxis 720 [0,0,1])
)
for o in sel do insertTime o.transform.controller -5 (random -299f 299f)
for o in sel do reverseTime o.transform.controller (random -299f 299f) (random -299f 299f)
wow that’s exactly what i wanted, thanks and well done on a clever bit of code!
Hi sorry to bring this post back up again the project was delayed for a bit, the animation doesn’t loop properly, how can I make it complete a loop (i’m using 300 for the length) ?
Thanks.
Hi again, there is a small work around for this. All u need to do is to set the last frame value equal to the first frame.
for o in sel do
(
at time 0 pos = o.transform
animate on (at time 300 o.transform = pos)
)
put that in the last line of the earlier code or select all the cubes run this:
sel = selection as array
for o in sel do
(
at time 0 pos = o.transform
animate on (at time 300 o.transform = pos)
)