Footstep script

#1

Hello everyone,

Im developing a small game on unity and I am going to use Fmod to implement sounds of any sort. But I’m struggling to run a footstep script I found from a tutorial on youtube (Scottgamesounds). the script looks like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Footsteps : MonoBehaviour {

     [FMODUnity.EventRef] 
     public string InputFootsteps;
     FMOD.Studio.EventInstance FootstepsEvent;
     FMOD.Studio.ParameterInstance WoodParameter;
     FMOD.Studio.ParameterInstance MetalParameter;
     FMOD.Studio.ParameterInstance GrassParameter;

     bool playerismoving;
     public float walking speed
     private float WoodValue;
     private float MetalValue;
     private float GrassValue;
     private bool playerisgrounded;

     void Start ()
     {
         FootstepsEvent = FMODUnity.RuntimeManager.CreateInstance(InputFootsteps);
         FootstepsEvent.getParameter ("Wood", out WoodParameter);
         FootstepsEvent.getParameter ("Metal", out MetalParameter);
         FootstepsEvent.getParameter ("Grass", out GrassParameter);

         InvokeRepeating ("CallFootsteps", 0, walkingspeed);
     }

     void Update () 
     {
         WoodParameter.setValue (WoodValue);
         MetalParameter.setValue (MetalValue);
         GrassParameter.setValue (GrassValue);

         if (Input.GetAxis ("Vertical") >= 0.01f || Input.GetAxis ("Horizontal") >= 0.01f || Input.GetAxis ("Vertical") <= -0.01f || Input.GetAxis ("Horizontal") <= -0.01f)
         {
             if (playerisgrounded == true) 
             {
                 playerismoving = true;
             } 
             else if (playerisgrounded == false) 
             {
                 playerismoving = false;
             }
         } 
         else if (Input.GetAxis ("Vertical") == 0 || Input.GetAxis ("Horizontal") == 0) 
         {
             playerismoving = false;
         }
     }

     void CallFootsteps ()
     {
         if (playerismoving == true) 
         {
             FootstepsEvent.start();
         } 
         else if (playerismoving == false) 
         {
             //Debug.Log ("player is moving = false");
         }
     }

     void OnDisable ()
     {
         playerismoving = false;
     }

     void OnTriggerStay(Collider MaterialCheck)
     {
         //float FadeSpeed = 10f;
         playerisgrounded = true;

         if (MaterialCheck.CompareTag ("Wood:Material")) 
         {
             WoodValue = 1f;
             MetalValue = 0f;
             GrassValue = 0f;
         }
         if (MaterialCheck.CompareTag ("Metal:Material")) 
         {
             WoodValue = 0f;
             MetalValue = 1f;
             GrassValue = 0f;
         }
         if (MaterialCheck.CompareTag ("Grass:Material")) 
         {
             WoodValue = 0f;
             MetalValue = 0f;
             GrassValue = 1f;
         }
     }

     void OnTriggerExit (Collider MaterialCheck)
     {
         playerisgrounded = false;
     }

The Main (Hopefully the only) problem is the usage of “FMOD.Studio.ParameterInstance” and “.getParameter” that unity doesn’t recognise. I think that libraries of Fmod have changed in the past so I cannot use these instances anymore.

Does anybody how to replace them correctly or have you any good advice to run this script properly?

Thanks.

#2

This is exactly what Visual Studio says

#3

This script will likely work in FMOD 1.10 but not without changes for 2.00 as the Parameter API has completely changed.

https://fmod.com/resources/documentation-api?version=2.0&page=welcome-whats-new-200.html#new-parameter-api