Godot Version
4.3
Question
I have followed this tutorial video https://www.youtube.com/watch?v=j_rf8zc5kTE and I have a CharacterBody3D Node which has this similar structure:
CharacterBody3D
Node3D # used for pivot
SpringArm3D
Camera3D
I would like to extend further from the Youtube Video above in that I will have a camera that smoothly jumps around between different cameras like this: https://www.youtube.com/watch?v=Vep3_3pQao0 1 (see 6:55 onward)
As I have multiple Camera3Ds in my scene already, I decided to create a main Camera3D called mainCamera
which will be the active current Camera3D jumping around from one target Camera3D to next, using the variablecameraOfInterest
. See this code here:
mainCamera.position = mainCamera.position.lerp( cameraOfInterest.global_transform.origin, delta*6 )
mainCamera.rotation.x = lerp( mainCamera.rotation.x, cameraOfInterest.rotation.x, delta*6 )
mainCamera.rotation.y = lerp( mainCamera.rotation.y, cameraOfInterest.rotation.y, delta*6 )
mainCamera.rotation.z = lerp( mainCamera.rotation.z, cameraOfInterest.rotation.z, delta*6 )
(Yes, this is the same code with my other topic but the issue discussed here is different)
There are no issues with the positioning, but for the rotation, there is an issue with a Camera3D that the cameraOfInterest
’s rotation axis is static. As I follow the tutorial Youtube video above, the code at 3:23, the CharacterBody3D’s y-axis is rotated and the pivoting Node3D (CamOrigin)'s x axis is being rotated. The camera’s rotation did not change, as its preceding parents are the entities being rotated.
Yes, I could retrieve the CharacterBody3D’s y-axis and CamOrigin’s x-axis and put into the code above, but in the future, if I have other constructs which have their own structures and hierarchy, this will not go well. So I would like to have a solution that just provide me the rotation Vector3D and disregard whatever structures the Camera3D is in.
Is it possible to get the Camera3D’s current rotation Vector3D with respect to all the preceding nodes’ rotation? How to do this in Godot 4?