integrate sound

This commit is contained in:
Cat Flynn 2021-01-11 12:42:43 +00:00
parent ffc3bbe283
commit f54ce99f07
3 changed files with 28 additions and 2 deletions

View File

@ -133,7 +133,7 @@ Material:
m_Colors: m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1} - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color1: {r: 0.3634766, g: 5.3403134, b: 0, a: 1} - _Color1: {r: 1.4539073, g: 21.361254, b: 0, a: 1}
- _Color2: {r: 0.24509804, g: 0.3764706, b: 0, a: 1} - _Color2: {r: 0.24509804, g: 0.3764706, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FarColor: {r: 1, g: 1, b: 1, a: 1} - _FarColor: {r: 1, g: 1, b: 1, a: 1}

View File

@ -29,6 +29,8 @@ public class EntityLives : MonoBehaviour
private void Die() private void Die()
{ {
FMODUnity.RuntimeManager.PlayOneShot("event:/hit");
--lives; --lives;
if (lives > 0) if (lives > 0)
{ {

View File

@ -1,6 +1,10 @@
using System; using System;
using System.Collections;
using System.Collections.Generic;
using FMOD;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using Debug = UnityEngine.Debug;
using PlayerInput = Input.PlayerInput; using PlayerInput = Input.PlayerInput;
public class PlayerShootInput : ShootInputBase public class PlayerShootInput : ShootInputBase
{ {
@ -25,6 +29,11 @@ public class PlayerShootInput : ShootInputBase
_actions.Default.Shoot.performed -= Shoot; _actions.Default.Shoot.performed -= Shoot;
} }
private void Start()
{
StartCoroutine(MakePewSounds());
}
private void Shoot(InputAction.CallbackContext obj) private void Shoot(InputAction.CallbackContext obj)
{ {
_isShooting = obj.ReadValueAsButton(); _isShooting = obj.ReadValueAsButton();
@ -35,4 +44,19 @@ public class PlayerShootInput : ShootInputBase
return _isShooting; return _isShooting;
} }
private IEnumerator MakePewSounds()
{
var wait = new WaitForSeconds(0.02f);
while (true)
{
if (_isShooting)
{
FMODUnity.RuntimeManager.PlayOneShot("event:/shoot");
}
yield return wait;
}
}
} }