123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- namespace VRTK.Examples.Old
- {
- using UnityEngine;
- public class FireExtinguisher_Sprayer : VRTK_InteractableObject
- {
- public FireExtinguisher_Base baseCan;
- public float breakDistance = 0.12f;
- public float maxSprayPower = 5f;
- private GameObject waterSpray;
- private ParticleSystem particles;
- public void Spray(float power)
- {
- if (power <= 0)
- {
- particles.Stop();
- }
- if (power > 0)
- {
- if (particles.isPaused || particles.isStopped)
- {
- particles.Play();
- }
- #if UNITY_5_5_OR_NEWER
- var mainModule = particles.main;
- mainModule.startSpeedMultiplier = maxSprayPower * power;
- #else
- particles.startSpeed = maxSprayPower * power;
- #endif
- }
- }
- protected override void Awake()
- {
- base.Awake();
- waterSpray = transform.Find("WaterSpray").gameObject;
- particles = waterSpray.GetComponent<ParticleSystem>();
- particles.Stop();
- }
- protected override void Update()
- {
- base.Update();
- if (Vector3.Distance(transform.position, baseCan.transform.position) > breakDistance)
- {
- ForceStopInteracting();
- }
- }
- }
- }
|