Problem with perfect Aiming at object in 3D space

Godot Version

Question

Hello everyone. I used this a code from a tutorial that was about an Homing-Missile.

I only added the .abs() after the Vector3.UP and .RIGHT.
I used this code to make my Gun-Turret look at the Enemy Ship in my game so that it can hit it when it fires. Now i think, if the turret rotates (on Y for example) 90° it moves in the negative range wich changes the Vector to a negative value. But its not only the Y Axis since the origin-info comes from ‘‘global_transform’’ it’s from time to time every Axis as soon as my and the enemy fly around and turn…

Outcome is: The turret firstly fires perfect at the target but after moving around in the space in any direction, it fires directly in the opposide direction or seems to ignore an Axis for looking precise on the target. I don’t think the code is useless for the 3D targeting but there must be something addet to fix this problem.

So my idea was to add .abs() to set the Vectors on Y and Z to a positive Value. But i knew that wont help because for horizontal movement (X) i need a positive and negative vector.

Im a little confused now and don’t know what i could do in this case.

Here is the code that i use. Lame upload restriction for newcomers… . It says add as much Details as you can for a Topic but you can only upload 1 picture as newcomer? Fail