using System.Collections; using System.Collections.Generic; using UnityEngine; #if FMOD_AVAILABLE using FMOD; using FMODUnity; #endif public class OnStirringSound : MonoBehaviour { #if FMOD_AVAILABLE [SerializeField] Rigidbody _rigidbody; StudioEventEmitter _stirringSoundEvent; void Start() { _stirringSoundEvent = GetComponent(); } void Update() { if (_rigidbody.velocity != Vector3.zero) { if (!_stirringSoundEvent.IsPlaying()) { _stirringSoundEvent.Play(); } } else { _stirringSoundEvent.Stop(); } } void OnDestroy() { _stirringSoundEvent.Stop(); } #endif }