How to fix 2D Blend position on a 3D space

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Onelio

I have a Sprite3D with an AnimationTree over a 3D space and wanted it to transition between perspectives according to the camera position so I did this:

# Process perspective
var trans = camera.get_camera_transform()
animationTree.set("parameters/Idle/blend_position", Vector2(trans.origin.x, trans.origin.z))

And this is the result:

There are some issues with the correct set of sprites to use when looking at it from the sides but that I can solve easily. My question is: How can I modify it so the “front” part is not always facing the same direction? I want it to face a Vector3 position given by me.

:bust_in_silhouette: Reply From: Onelio

I kind of fixed it… But I have a great case of “Not knowing what is this witchcraft” so if anyone can help me understand it, it would be much appreciated.

var p_fwd = (posObject - global_transform.origin).normalized()
var fwd = global_transform.basis.z
var left = global_transform.basis.x

var l_dot = * -1
var f_dot =
animationTree.set("parameters/Idle/blend_position", Vector2(l_dot, f_dot))

Source of inspiration: