Created
April 15, 2021 20:23
-
-
Save walterpalladino/19b3541772abd9805956b510d53c5dfd to your computer and use it in GitHub Desktop.
Unity 3D Billboard only facing Y to camera
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class BillboardFacingY : MonoBehaviour | |
{ | |
void Update() | |
{ | |
// look at camera... | |
transform.LookAt(Camera.main.transform.position, -Vector3.up); | |
// then lock rotation to Y axis only... | |
transform.localEulerAngles = new Vector3(0,transform.localEulerAngles.y,0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment