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:
parenting at every rotation cycle the 9 cubes I need to rotate and rotating the parent.
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?
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.
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.
I had also developed all logic for a rotating cube like you, but this exact issue came up for me too. Your solution of baking the rotation to the parent worked perfectly for me. Thanks for suggesting this on the forum!