Skip to content

Instantly share code, notes, and snippets.

@klaszlo8207
Last active January 18, 2023 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klaszlo8207/09cf0c72655b9d3ddb574e8e8686cada to your computer and use it in GitHub Desktop.
Save klaszlo8207/09cf0c72655b9d3ddb574e8e8686cada to your computer and use it in GitHub Desktop.
using UnityEngine;
namespace _MyScripts.Utils
{
public static class PlaneUtils
{
private static Camera _camera;
public static void PlaneRotateToCamera(GameObject go, float x, float y, float z)
{
if (_camera == null) _camera = Camera.main;
var direction = _camera.transform.position - go.transform.position;
go.transform.rotation = Quaternion.LookRotation(direction.normalized) * Quaternion.Euler(x, y, z);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment