Answered
0
0

Hi Everybody. I have a issue, i try to play a dynamic music, with triggerIn and triggerOut.

I start the game with a music, and i walk for the scene, i triggerEnter and change the parameter to sound other part of the music, i go out, and triggerExit change the parameter to other part of the music. The thing is that, if i arrive to a place where i can arrive for two differents ways, when triggerEnter in that place i should choose one or other parameter value, in function from i have arrived.

OK!!, How can i say to script, that if triggerEnter (player) and parametervalue is XX.Xf change to XY.Xf or if i triggerEnter (player) and parametervalues is otherXX.Xf (because i come from other side) change to YY:Yf parametervalue…???

i try this:

using UnityEngine;
using System.Collections;

public class McaIrish : MonoBehaviour {

MusicPipes MusicaC;

// Use this for initialization
void Start () {

    MusicaC = GameObject.Find ("Camera_low").GetComponent<MusicPipes> ();
    //MusicaC.Mca2.setParameterValue ("Strings", 0f);
}

void OnTriggerEnter (Collider hit){

    if (hit.GetComponent<Collider> ().CompareTag ("Player") && (MusicaC.M_Pipes.setParameterValue ("MUSIC", 2.46f)))
    {
        MusicaC.M_Pipes.setParameterValue ("MUSIC", 2.31f);
    } 
    else if (hit.GetComponent<Collider> ().CompareTag ("Player") && (MusicaC.M_Pipes.setParameterValue ("MUSIC", 0f)))

    {
    MusicaC.M_Pipes.setParameterValue ("MUSIC", 0.56f);
    }

}

}

if i make this, Unity say me this: “….Assets/McaIrish.cs(23,51): error CS0019: Operator &&' cannot be applied to operands of typebool’ and `FMOD.RESULT’…”

thanks for your help

  • You must to post comments
Best Answer
0
0

The function setParameterValue returns a FMOD.RESULT not a bool.
You can check if setParameterValue succeeds by seeing if it returns FMOD.RESULT.OK.
Something like:

 if (hit.GetComponent<Collider> ().CompareTag ("Player") && (MusicaC.M_Pipes.setParameterValue ("MUSIC", 2.46f) == FMOD.RESULT.OK))
 ...
  • You must to post comments
0
0

Hi, thanks for your advice, i try it, and unity doesn’t send me any erro, is ok, but this happens.

i have in the script:

void OnTriggerEnter (Collider hit){

    if (hit.GetComponent<Collider> ().CompareTag ("Player") && (MusicaC.M_Pipes.setParameterValue ("MUSIC", 2.47f) == FMOD.RESULT.OK)) {

        Debug.Log ("Funcionaaaa");

        MusicaC.M_Pipes.setParameterValue ("MUSIC", 2.32f);     

    }

    if (hit.GetComponent<Collider> ().CompareTag ("Player") && (MusicaC.M_Pipes.setParameterValue ("MUSIC", 0.01f) == FMOD.RESULT.OK)) {

        MusicaC.M_Pipes.setParameterValue ("MUSIC", 0.56f);
        Debug.Log ("AIXO MARCHAAA");


    }



}

and when arrive to the triggerZone, the console show me the two debug.logs messages, is like the script makes fmod.result.ok for all supouses. i think that fmod.result.ok would be like a bool to check the correct setParameterValue, that i am reproducing in this moment.

Thanks, for any other help.

  • You must to post comments
0
0

It sounds like you want to use getParameterValue rather than setParameterValue.
If you want to check if the object entering the trigger is the player and if the parameter “Music” is equal to a value, then set it to the new value, there are a couple ways to do this.

You could use getParameterValue to output the value of the parameter, only at that specific moment, into a float variable.
MusicaC.M_Pipes.getParameterValue("Parameter Name", out value, out finalvalue);

Using getParameter you can store a reference to the parameter, then get and set the value from that reference.
FMOD.Studio.ParameterInstance paramRef;
MusicaC.M_Pipes.getParameter("Parameter Name", out paramRef);
paramRef.getValue(out paramValue);

  • You must to post comments
0
0

Hi Cameron, thanks for all your time and all your advices, but i don’t achieve make it works.

i try this:

using UnityEngine;
using System.Collections;

public class McaIrish : MonoBehaviour {

MusicPipes MusicaC; //this comes from other script MusicPipes.cs Where are the fmod instance for the music.

void Start () {
MusicaC = GameObject.Find ("Camera_low").GetComponent<MusicPipes> (); //call the script MusicPipes.cs
}

void OnTriggerEnter (Collider hit){
    if (hit.GetComponent<Collider> ().CompareTag ("Player")){ //check if the GameObject is the "PLayer"
        MusicaC.M_Pipes.getParameterValue ("MUSIC", out 0f, out 0.56f); // Check if the parameter "MUSIC" is using paramValue 0f, and in this case change to 0.56f
    }
}

}

Unity tell me this errors:

Assets/McaIrish.cs(21,74): error CS1510: A ref or out argument must be an assignable variable
Assets/McaIrish.cs(21,85): error CS1510: A ref or out argument must be an assignable variable
Assets/McaIrish.cs(21,41): error CS1502: The best overloaded method match for FMOD.Studio.EventInstance.getParameterValue(string, out float, out float)' has some invalid arguments
Assets/McaIrish.cs(21,41): error CS1503: Argument
#2′ cannot convert object' expression to typefloat’

i will be very appreciate for your help.

Regards

David C.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.