CameraFollower.cs 1.0 KB

123456789101112131415161718192021222324252627282930
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace SC.XR.Unity {
  5. public class CameraFollower : FollowerBase {
  6. bool isInit = false;
  7. protected override void OnEnable() {
  8. base.OnEnable();
  9. isInit = false;
  10. }
  11. protected override void Follow() {
  12. if (API_GSXR_Slam.SlamManager?.head == null) {
  13. return;
  14. }
  15. if (isInit == false) {
  16. transform.position = CalculateWindowPosition(API_GSXR_Slam.SlamManager.head);
  17. transform.rotation = CalculateWindowRotation(API_GSXR_Slam.SlamManager.head);
  18. isInit = true;
  19. }
  20. transform.position = Vector3.Lerp(transform.position, CalculateWindowPosition(API_GSXR_Slam.SlamManager.head), WindowFollowSpeed * Time.deltaTime);
  21. transform.rotation = Quaternion.Slerp(transform.rotation, CalculateWindowRotation(API_GSXR_Slam.SlamManager.head), WindowFollowSpeed * Time.deltaTime);
  22. }
  23. }
  24. }