Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
523 B

3 years ago
3 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. [ExecuteInEditMode]
  5. public class LookAtCamera : MonoBehaviour
  6. {
  7. private void Awake()
  8. {
  9. UpdateRotation();
  10. }
  11. [ContextMenu("Update Rotation")]
  12. public void UpdateRotation()
  13. {
  14. var _cameraObj = Camera.main.gameObject;
  15. transform.rotation = _cameraObj.transform.rotation;
  16. transform.Rotate(new Vector3(0, 180, 0));
  17. }
  18. private void LateUpdate()
  19. {
  20. UpdateRotation();
  21. }
  22. }