ScheisseMan
I read your post carefully, and I have the picture that the problem is not an issue with rotate_toward() but Euler angle problem.
Note that from the best of my knowledge in Godot, rotation.x/y/z are rotation angles. When the pitch (x) approaches ±90°,Godot may start flipping the values internally between equivalent rotations. This cause an effect, where you may observe, sudden spinning, jittering, or snapping and the further past 90° you go, the worse it gets.
Now in terms of print(aim_target) it is highly possible that you observe values suddenly jumping between things like:Vector3(1.57, 0, 0) and Vector3(1.57, 3.14, 3.14) as well. Though these are mathematically equivalent orientations, rotate_toward() sees a huge difference and the result is that it is trying interpolate between them. Consequentially, the result is that print(aim_target) looks very weird…
In your case I would not interpolate Euler components independently and I would use quaternions/basis(because from your saying you want a spacecraft that can freely pitch through 360°).
Below,is the code I would use to interpolate the whole orientation:
var target_quat = Quaternion(camera.global_basis)
var current_quat = Quaternion(global_basis)
var result = current_quat.slerp(
target_quat,
MANUVERABILITY * delta
)
global_basis = Basis(result)
Hope this helps,
Alex