I have a basic NPC with aim offset animations and forward spatial node for aiming.
The spatial node is tracking a player with look_at function. How do I match aiming blends with the rotation of the forward spatial node? Do I even need this extra node?
Here's my code:
forward.look_at(player.global_transform.origin, Vector3.UP)
var forward_facing = forward.transform.basis.z
animation_tree["parameters/fire/aim_x/blend_amount"] = forward_facing.x
animation_tree["parameters/fire/aim_y/blend_amount"] = forward_facing.y
The Y axis works (for example when I jump NPC is looking up as it should), but X is all over the place. X value should somehow change with the global position in the world. Aiming blends are simple Blend3 nodes with ranges going from -1 to 1.
Here's an image, basically a red arrow – where it aims, a blue arrow – where it should aim (an invisible forward spatial node looks at player, as it should).

Thanks!