Last active
April 26, 2023 16:01
-
-
Save Hamcha/6096910 to your computer and use it in GitHub Desktop.
Stupid Unity scripts: 2D Billboards with perspective 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 Sprite2D : MonoBehaviour { | |
public Camera gameCamera; | |
private float initialRotation; | |
void Start() | |
{ | |
initialRotation = transform.rotation.z; | |
} | |
void Update() | |
{ | |
transform.rotation = gameCamera.transform.rotation; | |
transform.Rotate(Vector3.up * initialRotation * 180); // Fix Rotation (Flipped sprites) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
im slowly trying to fix the camera for my game, this fixed a rotation bug i had, thx!!!