#How to rotate an object around another object

4 messages · Page 1 of 1 (latest)

twin grove
#

I have a cube with a fixed position and fixed rotation, which I'll call RootCube. I want another cube, which I'll call RotatingCube, to spin around this cube on the x-axis. This I can do with this code:

rotating_cube.rotate_around(
    root_cube.translation,
    Quat::from_euler(EulerRot::XYZ, 1.5 * time.delta_seconds(), 0.0, 0.0),
);

But the RootCube has a rotation on the y-axis, and I want the RotatingCube to also account for that so its always aligned with that. So its orbit on the x-axis should be rotated on the y-axis by the amount that RootCube is rotated on the y-axis.

In the next message is my code that already has the rotation (orbit) on the x-axis.

Bonus question: why is there a jagged edge when the cubes overlap?

vernal vapor
#

Would parenting do what you want?