0 votes

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:
enter image description here

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.

Godot version 3.4.2
in Engine by (19 points)

1 Answer

0 votes
Best answer

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 = left.dot(p_fwd) * -1
var f_dot = fwd.dot(p_fwd)
animationTree.set("parameters/Idle/blend_position", Vector2(l_dot, f_dot))

Source of inspiration: https://www.youtube.com/watch?v=q0sLPbyIbQg

by (19 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.