UP-Viagg-io/Viagg-io/Assets/Scripts/Audio/OnStirringSound.cs

43 lines
763 B
C#

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<StudioEventEmitter>();
}
void Update()
{
if (_rigidbody.velocity != Vector3.zero)
{
if (!_stirringSoundEvent.IsPlaying())
{
_stirringSoundEvent.Play();
}
}
else
{
_stirringSoundEvent.Stop();
}
}
void OnDestroy()
{
_stirringSoundEvent.Stop();
}
#endif
}