Assignment for RMIT Mixed Reality in 2020
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.

39 lines
1.0 KiB

  1. namespace VRTK
  2. {
  3. using UnityEngine;
  4. public class SDK_ControllerSim : MonoBehaviour
  5. {
  6. [HideInInspector]
  7. public bool selected;
  8. protected VRTK_VelocityEstimator cachedVelocityEstimator;
  9. protected float magnitude;
  10. protected Vector3 axis;
  11. public Vector3 GetVelocity()
  12. {
  13. SetCaches();
  14. return cachedVelocityEstimator.GetVelocityEstimate();
  15. }
  16. public Vector3 GetAngularVelocity()
  17. {
  18. SetCaches();
  19. return cachedVelocityEstimator.GetAngularVelocityEstimate();
  20. }
  21. protected virtual void OnEnable()
  22. {
  23. SetCaches();
  24. }
  25. protected virtual void SetCaches()
  26. {
  27. if (cachedVelocityEstimator == null)
  28. {
  29. cachedVelocityEstimator = (GetComponent<VRTK_VelocityEstimator>() != null ? GetComponent<VRTK_VelocityEstimator>() : gameObject.AddComponent<VRTK_VelocityEstimator>());
  30. }
  31. }
  32. }
  33. }