- Home /
Game Texture - Always Face Camera
Hello,
Before you say this question has been asked multiple times, bear with me (it's different)...
I want to get a texture within my scene to face my camera at a certain way. When I use:
transform.LookAt(Camera.main.transform);
It works fine, but I want my texture to appear more like a GUI, but with depth (so you can't see it behind a game object).
Let me show:
Both the alert textures have the LookAt camera attached to them, and as you can see - its working, but not how I want.
This is how I want them to look. No matter where I am facing, the textures will always point 'directly' down the scene (instead of directly at the cloud point of the camera.
Any ideas how I can achieve this?
Answer by fafase · Sep 13, 2013 at 02:50 PM
Could it be that you do not want them to face your position but instead to align with the opposite of your forward vector?
transform.rotation = Quaternion.LookRotation(-Camera.main.transform.forward);
Exactly what I'm looking for. Could you do me one more? Could you make it so I can tweak the x, y, z rotation variables (for example, my texture it now facing in the opposite direction - so I need to rotate it +180, on top on this code.
Thanks
I don't quite get it. If your texture is facing the opposite way, just remove the - from Camera.main.transform.forward. What do you mean by tweaking values?
I think he means to add on to the values like this
float x = Camera.transform.forward.x + #number here#;