zerohootsoliver
Blargh! 😃
You're making things more complicated than they need to be. And I think our terminologies are not in tune. By "target" I mean the player entity that camera follows.
Let's start over. Forget bases, quaternions and rotations in general.
We want our camera to follow the player avatar which happens to be a rabbit. We only need two nodes:
- camera - The Camera3D node.
- rabbit - The player avatar that runs around the meadow. Any 3d node will do.
We want the camera to always be positioned and oriented the same way relative to the rabbit. So the picture of rabbit is always the same size and from the same angle. Exactly as if camera was rabbit's child node (but it isn't)
To position the camera in such a way we need two points:
- the point at which camera hovers
- the point it looks at
These two points are always the same from rabbit's perspective. The rabbit shall complain: "This damn camera is following me around, hovering at 2 meters above the ground and it's always 5 meters behind me and 1 meter on the right. Always. And it's always aimed at the meadow exactly 1 meter in front of me."
So the two points the camera is interested in are:
- position: (1, 2, 5) from rabbit's nose
- lookat: (0, 0, -1) from rabbit's nose
The camera always wants to be/look at these points. Otherwise the rabbit's picture will not be nice. But the problem is; the camera is not the rabbit. It needs to know where those points are in respect to the giant pine tree in the center of the meadow (global space), not in respect to rabbit's nose. So it can easily find where to go/look starting from that giant pine tree.
Camera then brings along its robot friend for help, and says to them:
var i_must_go_to = rabbit.to_global( Vector3(1, 2, 5) )
var i_must_look_at = rabbit.to_global( Vector3(0, 0, -1) )
self.global_position = i_must_go_to
self.look_at(i_must_look_at, Vector3.UP)
Finally the camera smiles and says: I will do this every frame, and rabbit will not ever be able to hide from my gaze.