Hi folks,
New to FMOD and trying to figure out how to get footstep audio implemented probably, Within FMOD I have everything setup to play a random assortment of footsteps with each step however within UNITY, it seems to think that the player is always moving and not only loops the audio, but plays multiple instances of it.
I’ve attached my code below and would appreciate any help! Thanks!
public class TestFootStep : MonoBehaviour {
[FMODUnity.EventRef]
public string inputsound;
public bool playerIsMoving;
public float walkingSpeed;
float horizontal;
float vertical;
void Update()
{
Debug.Log (playerIsMoving);
if (Input.GetKey (KeyCode.A))
playerIsMoving = true;
if (Input.GetKey(KeyCode.D))
playerIsMoving = true;
if (Input.GetKey(KeyCode.W))
playerIsMoving = true;
if (Input.GetKey (KeyCode.S))
playerIsMoving = true;
else
playerIsMoving = false;
}void FixedUpdate ()
{}
void FootStepsAudio(){
if (playerIsMoving == true) {
FMODUnity.RuntimeManager.PlayOneShot (inputsound);
}
}void Start (){
InvokeRepeating (“FootStepsAudio”, 0, walkingSpeed);
}
void OnDisable(){
playerIsMoving = false;}
}