# Rotation baking for a small brain

Hi,

it’s all day I’m trying to achieve something that I’m sure is incredibly easy for many of you but seems unreachable to my little brain.
I’m trying to animate a series of cubes with the same mechanics of a rubik cube, you can see what I did here:

https://www.claudiodallabernardina.com/works/generative/kaleidokubes_5/

I tried some different ways:

1. animating directly the cubes
2. parenting at every rotation cycle the 9 cubes I need to rotate and rotating the parent.
3. using bakeTransformIntoVertices

What I can’t manage to do is to bake the rotation at each cycle to the cubes so that at the next rotation the axis are aligned with the world axis.

Reading online I’ve understood that a proper way to do this would be to apply the parent matrix to the cubes before unparenting them and reparenting the new group for the next rotation.
But I cannot properly implement any of those solutions and I keep having issues at every try.

Please enlighten my way, which is the right way to obtain what I want to do?

Thank a lot,
Claudio

I finally did it using this approach:

1. parent.bakeCurrentTransformIntoVertices()
2. children.parent = null
3. childrenToRotate.parent = parent
4. rotate

repeat form point 1

My mistake was that I was trying to bakeTheTransform to the children cubes instead of the parent

You can do it without baking, using ‘setParent’ instead of ‘parent =’. ‘setParent’ looks to preserve physical properties from a world space perspective across setting parents.

This post might help

1 Like

Thanks a lot, that’s exactly what I was looking for!

Edit:
I tried to use setParent(newParent) to add parent and setParent(null) when removing but I still have the issues I had before I used baking. Maybe I’m doing something wrong, anyway i’ll stick with the working solution cause it is fine for what I need.

1 Like

Sorry to hear it didn’t work out. Love your example though, very beautiful