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.

32 lines
877 B

  1. namespace VRTK.Examples
  2. {
  3. using UnityEngine;
  4. public class Whirlygig : VRTK_InteractableObject
  5. {
  6. float spinSpeed = 0f;
  7. Transform rotator;
  8. public override void StartUsing(VRTK_InteractUse currentUsingObject = null)
  9. {
  10. base.StartUsing(currentUsingObject);
  11. spinSpeed = 360f;
  12. }
  13. public override void StopUsing(VRTK_InteractUse previousUsingObject = null, bool resetUsingObjectState = true)
  14. {
  15. base.StopUsing(previousUsingObject, resetUsingObjectState);
  16. spinSpeed = 0f;
  17. }
  18. protected void Start()
  19. {
  20. rotator = transform.Find("Capsule");
  21. }
  22. protected override void Update()
  23. {
  24. base.Update();
  25. rotator.transform.Rotate(new Vector3(spinSpeed * Time.deltaTime, 0f, 0f));
  26. }
  27. }
  28. }