VirtualNose.cs 986 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. namespace SicknessReduction.Visual
  3. {
  4. public class VirtualNose : MonoBehaviour
  5. {
  6. public GameObject prefabToSpawn;
  7. private Camera cam;
  8. private bool camAvailable;
  9. private GameObject nose;
  10. private void Start()
  11. {
  12. cam = Camera.main;
  13. if (cam == null)
  14. {
  15. Debug.LogWarning("No main camera found. Cannot place virtual nose!");
  16. return;
  17. }
  18. else
  19. {
  20. camAvailable = true;
  21. }
  22. nose = Instantiate(prefabToSpawn, cam.transform);
  23. nose.transform.localPosition = Vector3.forward * cam.nearClipPlane;
  24. }
  25. private void Update()
  26. {
  27. //if (!camAvailable) return;
  28. //var camTransform = cam.transform;
  29. //transform.position = camTransform.position + camTransform.forward * cam.nearClipPlane * 1.03f;
  30. }
  31. }
  32. }