#Local rotation and world rotation

1 messages · Page 1 of 1 (latest)

timber owl
#

Can you please help me understand why we use local for the second one and also why not use local for the first one
rotation = Vector3.zero;
rotation.y = lookAngle; // rotation around y axis
targetRotation = Quaternion.Euler(rotation); // Quaternion.Euler(0,lookAngle,0)
transform.rotation = targetRotation; // transform.rotation = Quaternion.Euler(0,lookAngle,0)

rotation = Vector3.zero;
rotation.x = pivotAngle;
targetRotation = Quaternion.Euler(rotation); // Quaternion.Euler(pivotAngle, 0, 0)
cameraPivot.localRotation = targetRotation

#

also, is there a way to see rotations of both camera manager and camera pivot like this? it would greatly help me understand

timber owl
#

wait so tell me if im wrong but what i understood is, if i use rotation, it will rotate around worlds x axis, but when i say local, it rotates around its own x axis

#

parents own x axis i meant

#

well i didn't mean that but i changed my mind xD

untold pawn
# timber owl wait so tell me if im wrong but what i understood is, if i use rotation, it will...

Hey! I just wanted to say that's exactly what it means. You can probably understand this in a more visual way by changing from local to global (or vice versa) in the scene window by pressing X or changing it manually from the toolbar. If you rotate a game object, you will see that its transform arrows are also rotated while having local selected, but in world space, the arrows will appear always the same.

untold pawn
# timber owl Can you please help me understand why we use local for the second one and also w...

In this case, you use world space rotation on the Y axis because you want to, regardless its rotation component, turn the camera around the character. But when it comes to the X axis, you probably want to rotate the camera to its sides, but worldspace will be wrong because it will not use your current camera X axis, but the world's one, so if your camera is facing to the ground, the X axis of the world will actually be like the Z axis of the cam, so it will rotate in a unwanted way

timber owl
#

i tried changing cameraPivot.localRotation to cameraPivot.rotation and what happens is, when camera manager rotates, camera pivot doesn't rotate even though its parent rotates

#

so when i say rotation, does it not care about its parents rotation at all?