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.

44 lines
979 B

  1. using Oculus.Avatar;
  2. public class OvrAvatarTouchController : OvrAvatarComponent
  3. {
  4. public bool isLeftHand = true;
  5. ovrAvatarControllerComponent component = new ovrAvatarControllerComponent();
  6. void Update()
  7. {
  8. if (owner == null)
  9. {
  10. return;
  11. }
  12. bool hasComponent = false;
  13. if (isLeftHand)
  14. {
  15. hasComponent = CAPI.ovrAvatarPose_GetLeftControllerComponent(owner.sdkAvatar, ref component);
  16. }
  17. else
  18. {
  19. hasComponent = CAPI.ovrAvatarPose_GetRightControllerComponent(owner.sdkAvatar, ref component);
  20. }
  21. if (hasComponent)
  22. {
  23. UpdateAvatar(component.renderComponent);
  24. }
  25. else
  26. {
  27. if (isLeftHand)
  28. {
  29. owner.ControllerLeft = null;
  30. }
  31. else
  32. {
  33. owner.ControllerRight = null;
  34. }
  35. Destroy(this);
  36. }
  37. }
  38. }