2 working sounds, updated scripts, fmod events
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using FMOD.Studio;
|
||||
|
||||
namespace _PROJECT.Components.Drawing
|
||||
{
|
||||
@@ -18,16 +19,26 @@ namespace _PROJECT.Components.Drawing
|
||||
private float _cooldownTimer = 0f;
|
||||
private bool _isSpraying;
|
||||
|
||||
private EventInstance spray_sound;
|
||||
|
||||
protected override void OnActivated(ActivateEventArgs args)
|
||||
{
|
||||
base.OnActivated(args);
|
||||
StartSpray();
|
||||
|
||||
spray_sound = AudioManager.Instance.CreateInstance(FMODEvents.Instance.Spray);
|
||||
spray_sound.setParameterByName("SpraySwitcher", 0); //"Spray - 0 in FMOD"
|
||||
spray_sound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(sprayPoint));
|
||||
spray_sound.start();
|
||||
}
|
||||
|
||||
protected override void OnDeactivated(DeactivateEventArgs args)
|
||||
{
|
||||
base.OnDeactivated(args);
|
||||
StopSpray();
|
||||
|
||||
spray_sound.setParameterByName("SpraySwitcher", 1); //"NoSpray - 1 in FMOD"
|
||||
spray_sound.release();
|
||||
}
|
||||
|
||||
private new void Awake()
|
||||
@@ -43,21 +54,37 @@ namespace _PROJECT.Components.Drawing
|
||||
_isSpraying = true;
|
||||
trigger.transform.Rotate(0f, 0f, -8.5f);
|
||||
sprayPart.Play(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void StopSpray()
|
||||
{
|
||||
|
||||
|
||||
_isSpraying = false;
|
||||
trigger.transform.Rotate(0f, 0f, 8.5f);
|
||||
sprayPart.Stop(true, ParticleSystemStopBehavior.StopEmitting);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isSpraying)
|
||||
{
|
||||
spray_sound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(sprayPoint));
|
||||
}
|
||||
|
||||
if (!isSelected || !_isSpraying)
|
||||
{
|
||||
if (!sprayPart.isPlaying) return;
|
||||
sprayPart.Stop(true, ParticleSystemStopBehavior.StopEmitting);
|
||||
|
||||
spray_sound.setParameterByName("SpraySwitcher", 1); //"NoSpray - 1 in FMOD"
|
||||
spray_sound.release();
|
||||
|
||||
_isSpraying = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user