0
0

Can someone please tell me now to change a parameter overtime in unity C# script. I’ve been trying everything I can think of and can’t figure out how to do it. I can get the parameter to jump to different points, but I can’t get it to be a gradual change. Like fade from 1 type of music to another. I think I need to use the getParameter or something. All help is appreciated.

Here is my code:
[code:25i7t5jv]
using UnityEngine;
using System.Collections;

public class soundManager : MonoBehaviour {
FMOD_StudioSystem soundSystem;

public FMODAsset asset;
FMOD.Studio.EventInstance evt;
    //FMOD.Studio.ParameterInstance pMusic;

// Use this for initialization


void Start ()
    {

    soundSystem=FMOD_StudioSystem.instance;

    evt = FMOD_StudioSystem.instance.GetEvent(asset.id);

}  


// Update is called once per frame
void Update () 

{


    if (Input.GetKeyDown ("p"))
        {
        evt.start();

    }

    //change an events parameters based on a key input:

    if (Input.GetKeyDown ("o")) 

    {

            evt.setParameterValue ("music", 1.0F) 

    }

    if (Input.GetKeyDown ("i")) {

        evt.setParameterValue ("music", 0.0F);

    }

}

[/code:25i7t5jv]

  • You must to post comments
0
0

First thanks both of you for the suggestions.

@ Peter, thanks for the coroutine stuff. You can probably tell I’m new to programming, but slowly getting the hang of it. I was able to figure it out using a coroutine and it works great.

Although I am curious about seek speed. What is it? where do I find it. I googled and looked in the fmod docs, but I didn’t find any thing. Any thoughts of where I can lean about it?

  • You must to post comments
0
0

You need to either interpolate the value you’re passing in your code, or increase the "seek speed" in your FMOD Studio Project .

  • You must to post comments
0
0

Seek speed is a good option, that offers linear interpolation to smooth out parameter changes. If you want more control you could update the parameter each frame from Update or using a [url=http://docs.unity3d.com/Manual/Coroutines.html:4papii59]Coroutine[/url:4papii59]

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.