The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

im new at godot, and I have tried to make a Sprite 3D always turn to see my first person player, but I can not do it correctly. I tried the billboard function but the Sprite looks strange because it does not remain static to the ground, I move the camera and the sprite lengthens or shrinks in order to see itself, and that's not what I want, what I want is that only its "Y" rotation always change giving me the face, something similar to danganronpa so you can understand perfectly what I'm looking for. Maybe that can be solved with GDscript in the Sprite, but I have not managed to do it, do you know any effective way to do it? I have surrendered with the billboard function that is what everyone talks about and without much info, I can not find any tutorial that can do what I want, I would appreciate any help :(

in Engine by (16 points)

2 Answers

+4 votes
Best answer

The billboard function should not shrink or lengthen the sprite, it should just make it look at you.

If you want only the Y rotation to change, maybe this can do it:

func _process(delta):
    var camera_pos = get_viewport().get_camera().global_transform.origin
    camera_pos.y = 0
    look_at(camera_pos, Vector3(0, 1, 0))

I think there is a way using a custom shader but I don't have the math in mind.

Edit: oh wait, there is an Y-billboard mode in SpatialMaterial... I tried it and it works well, why is this not suitable? Are you using Godot 2 or 3?

by (29,360 points)
selected by

Ok i tried your code and i think we're so much close, the only problem is that when im in front of the sprite this one inclines to me, and if i pass through him he gives a 360° turn in X axis, but dude thank you finally something works :D

About Y-Billboard i tried that too and actually it works perfectly, the problem? i dont know why but the sprite turns fat, literally, its X-Scale grows and i cant change it even if i use the Scale Mode or if i manually decrease its X-Scale in Inspector menu, but the Y rotation works perfectly, using Godot 3. Now, being a SpatialMaterial, i put the Transparent, Unshaded and Albedo Tex For flags in order to make it visible and in good quality, im not sure if one of those flags makes the Y-billboard not suitable (pretty much sure its not that) or maybe my sprite was made wrongly (could be), or maybe is my version of godot, are you using godot 2?

You know what? i think its my sprite, maybe it is wrong after all, im drawing a character in flash professional cc, and then i export it as a sprite sheet, i guess thats the problem, because after trying the Y-billboard with the godot icon worked well, so it seems that the real question is how can i make my flash drawing a sprite correctly? how do you make your sprites? any program in particular?

Ugh, well any PNG or atlas should work normally. If an atlas causes problems then you probably hit a bug^^ Do you have an example project I can checkout?

Hey buddy dont worry, i finally solved it! using Y-Billboard function, but thank you for all the help, i appreciate it, actually if you hadnt mentioned the billboard i wouldnt insist with it and i would be struggling. Thank you!!

This worked wonderfully. Thanks.

0 votes

To make the correct answer more obvious, here's AlexTheRegent's answer to a similar question:

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.

These Flags work for Label3D too!

by (154 points)
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 Frequently asked questions and 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 [email protected] with your username.