Adding the scene component Azimuth Gimbal fixed the rotation issue but I don’t understand why, can someone offer another explanation for it?
If I’m understanding correctly, I’ll try my best to explain it. The camera is mounted to the spring arm which only rotates on it’s own Y axis. The spring arm is anchored to the gimbal which only rotates on it’s own Z axis. all of which is anchored to the tank. if the tank turns everything down to camera follow without changing their relative values. If the gimbal turns the spring arm and camera follow without changing their relative values.
If we simply kept it on one system and rotated in both y and z the camera would inherit the rotation and as we swivel around the y and z axes would change orientation. or:
This eventually, if multiple crossbody/crosstank movements would cause the camera to flip around. You are basically making the Y axis a Z axis and the Z axis an X axis (don’t quote me on the exact) if you look straight down at the tank, and continuing to move it about. Did I explain it well enough?
The first thing you must realize is that, in 3D space, the order of rotations matters. You can test it in the real world with any object. Try this with your cell phone, for example:
- Put your cell phone on the desk in front of you, with the screen facing up and on the vertical orientation.
1.1. Imagine an axis coming up through the middle of the screen. Rotate the phone 90 degrees about that axis. It should still lie on the desk, but on the horizontal orientation.
1.2. Imagine an axis from the bottom to the top of the screen. Rotate the phone 90 degrees about that axis, so that the screen is facing you. - Put your cell phone back as it started on the desk.
2.1.This time, start by rotating the phone 90 degrees about the axis from the bottom to the top of the screen. You will probably have to hold it to keep it from falling over.
2.2. Now imagine how the phone would rotate about the axis coming through the middle of the screen. Notice that no rotation around that axis can make the screen face you as before.
You can experiment with any object and any two rotations (90 degrees makes it easier). If you repeat the rotations about the same axes but in the opposite order, the final resulting orientation will be different.
Now consider the tank sitting still on the ground. Its aim is determined by two rotations: first, the azimuth/yaw of the turret, then, the elevation/pitch of the barrel. If these two rotations are done in that order, the resulting aim will have no roll (this is obvious from the physical behavior of real tanks). This means the following sequence of rotations:
Yaw --> Pitch
On the other hand, before adding the azimuth gimbal, the mouse controlled both the yaw and the pitch of the springarm. So, if you moved the mouse in X, then Y, then X, then Y, you would have:
Yaw --> Pitch --> Yaw --> Pitch
After adding the azimuth gimbal, we separated the rotations. All mouse movements in X contribute to a single combined yaw (applied on the gimbal), which comes before the single combined pitch of all mouse movements in Y (applied on the springarm):
Yaw --> Yaw --> Pitch --> Pitch == ResultingYaw --> ResultingPitch
This last behavior is different from the one before (because the order of rotations matter), and it mimics what happens with the tank’s turret and barrel, making sure that the resulting rotation is a yaw followed by a pitch, and nothing more.