Created
May 19, 2019 22:27
-
-
Save bfollington/b8f500b71cdb4ce54d6a1d6d5df40628 to your computer and use it in GitHub Desktop.
A tiny MonoBehaviour for Unity3d that makes a sprite look at the camera
This file contains hidden or 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; | |
using System.Collections; | |
public class FaceCamera : MonoBehaviour { | |
public bool LockX = false; | |
public bool LockY = false; | |
void Start () { | |
} | |
// Update is called once per frame | |
void LateUpdate () { | |
transform.rotation = Quaternion.Euler( | |
LockX ? 0 : Camera.main.transform.rotation.eulerAngles.x, | |
LockY ? 0 : Camera.main.transform.rotation.eulerAngles.y, | |
0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment