0 votes

So I'm trying to have an object in 3D space always face the camera. I've actually gotten it to work, but the object's position and scaling are completely lost when I use looking_at

Here is the code I'm using:

transform = transform.looking_at(cam.translation, Vector3(0 ,1, 0))

And the outcome when called:

before: 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1 - 0, 1.43091, 1.76425
after: 0.279935, -0.200516, 0.938845, 0, 0.977944, 0.208866, -0.960019, -0.058469, 0.273761 - 0, 1.43091, 1.76425

When I spawn multiple instances of the object they all immediately move to the same space so I'm guessing that I'm using the method incorrectly. Any help would be appreciated, thanks!

in Engine by (58 points)

1 Answer

+1 vote
Best answer

So I'm trying to have an object in 3D space always face the camera.

OK, quick cheat for this.
The Spatial Material has a billboard setting. After you made the material go to Parameters -> Billboard Mode and select a option from the drop down; works with any mesh.

object's position and scaling are completely lost when I use looking_at

I think this is a bug, it looks like a normelized version of the basis is used for lookat() and lookingat()

by (1,445 points)
selected by

Ya that certainly helps!

I'll post about it in the Discord and hope it can get further cleared up, thanks!

Please fill me in if you get a answer to the looking at problem.

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.