# How to rotate instanced objects on Z-axis using geometry nodes to match face rotation

I've got a mesh with two separate faces that each have a cube on them. I would like the cube attached to a specific face to rotate to match the face as that face rotates. I'm pretty new at geometry nodes so I might be misunderstanding this, but I believe the issue is that the Z-axis has no reference point for a face as it rotates. (See image of monkey heads as explained in https://www.youtube.com/watch?v=Fl-igAAMCeM.

In the image below you can see that I have two faces in one object. I want to rotate the face on the right by 45 degrees (or however much is necessary) so that the edges of the cube rotate with the edges of the face. As is shown the cube itself doesn't rotate as is the goal.

One other concern is that I would sometimes like to do rotations up to 180 degrees when I need to display the opposite side of the cube. In this instance, the "largest-y" edge would become the "smallest-y", so doing it based on vertex position hasn't given me much success when trying to perform face tangents based on edge position.

After many trials, I've reverted to the following geometry nodes, just for simplicity's sake of this post.

As a final note, X and Y rotate just fine, it's purely the Z axis that I need help with. I do have a workaround but that involves creating copies of the object, and I'd prefer to keep them all as the same object, but with multiple faces.

Thank you so much in advance and let me know if I need to send any more info. Also, I looked through dozens of "similar" questions but I may have still missed something. Sorry if that's the case.

• I think this helps: blender.stackexchange.com/a/277891/60486 Dec 7, 2023 at 22:01
• This one worked partially, but as soon as I add another plane to the object, the Z rotations become distored due to positioning. I'll have to see if I can figure out more with it. Dec 8, 2023 at 7:39

## 1 Answer

It's the same principle as here:

Trying to align multiple instances of an object normal to faces using geometry nodes

Except there I aligned to the bottom, and since you want consistency in animation, you want to align by topology - so below I pick the first edge of the first vertex of each face, and align to that (edge's center):

Notice how the eyes of Suzanne aren't symmetric. This is because the first edge of first vertex relation isn't mirrored. You could use a different logic to align, for example only use first vertex (no need to get the first edge of it) to get the rotation, compare with the actual z-rotation obtained otherwise (e.g. align up), do that on frame 1, do again on current frame, and the difference in angles is the additional rotation you need to apply…

• I'm so sorry, I went to bed before I could look into your other response more, but thank you so much. Both responses were wonderful, but the second one worked flawlessly right off the bat! Dec 8, 2023 at 14:38