Changing scale based on rotation
So I'm trying to make a GUI in a 3D scene, and the GUI follows the camera rotation x, y, and z. The GUI rotates accordingly, but when it rotates it the scale seems to make it appear stretched, and thinner than it actually is. Anyway around this?
------------- Code ---------------- {
public Transform cameraTransform;
public float distanceFromCamera;
void LateUpdate()
{
transform.LookAt(cameraTransform);
transform.localScale = transform.localScale * new Vector3(transform.rotation.x, 1, 1);
Vector3 resultingPosition = cameraTransform.position + cameraTransform.forward * distanceFromCamera;
transform.position = resultingPosition;
}
}
Comment
Your answer
Follow this Question
Related Questions
Question on Textbox Margin and Size limitations,Scaling margin on text box 0 Answers
Scaling animation that takes rotation into account 0 Answers
How can I get a rigid body object to face in the direction my joystick is pointing smoothly? 0 Answers
Player position relative to rotating platform [gif included] 0 Answers
[SOLVED] - Issues with Character Controller and Moving Platform 1 Answer