How to make a 3D sprite always look at the player in strait way

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

Hi buddies

thank you for your help in advance
func _process(delta: float) → void:
var camera_pos = get_viewport().get_camera().global_transform.origin
camera_pos.y = 0
look_at(camera_pos, Vector3.UP)

I used this code for my flat plane in Godot v3.3.4, its working but it has an issue, the problem is when I get close to the sprite on 3D view , my plain rotate in x or z axis,in other word flat sprite will band towards the camera (its because origin of the sprite is facing to the camera on the character head)
another issue is what if I have more than one camera on the scene!
so in this case “Look_at” will chose which one?

About billboard method , its working but it has another issue which is when I`m going behind the flat plain my artwork (sprite) gonna flip or upside down.

I think the solution is, put a 3D position in foot of character and link “look_at” to that point instead of camera on the head.what you guys think?
but how can I find that 3D position on player scene from other sprite scene!?

:bust_in_silhouette: Reply From: AlexTheRegent

You probably need to set Flags > Billboard to Y-Billboard at your Sprite3D node. This way, it should always face active camera, no matter how many of them you have.

1 Like