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.

53 lines
1.4 KiB

  1. namespace VRTK.Examples.Old
  2. {
  3. using UnityEngine;
  4. public class FireExtinguisher_Sprayer : VRTK_InteractableObject
  5. {
  6. public FireExtinguisher_Base baseCan;
  7. public float breakDistance = 0.12f;
  8. public float maxSprayPower = 5f;
  9. private GameObject waterSpray;
  10. private ParticleSystem particles;
  11. public void Spray(float power)
  12. {
  13. if (power <= 0)
  14. {
  15. particles.Stop();
  16. }
  17. if (power > 0)
  18. {
  19. if (particles.isPaused || particles.isStopped)
  20. {
  21. particles.Play();
  22. }
  23. #if UNITY_5_5_OR_NEWER
  24. var mainModule = particles.main;
  25. mainModule.startSpeedMultiplier = maxSprayPower * power;
  26. #else
  27. particles.startSpeed = maxSprayPower * power;
  28. #endif
  29. }
  30. }
  31. protected override void Awake()
  32. {
  33. base.Awake();
  34. waterSpray = transform.Find("WaterSpray").gameObject;
  35. particles = waterSpray.GetComponent<ParticleSystem>();
  36. particles.Stop();
  37. }
  38. protected override void Update()
  39. {
  40. base.Update();
  41. if (Vector3.Distance(transform.position, baseCan.transform.position) > breakDistance)
  42. {
  43. ForceStopInteracting();
  44. }
  45. }
  46. }
  47. }