0
0

Hey Fmod,

I’m trying to set the value of an event parameter depending on a gameObject transform position. The Object’s position keeps changing at runtime, but I’d like the value of the parameter to be set according to the Object’s initial position when it is created (on a click-based sets of coordinates). I’m using a prefab to instantiate the object and would like the parameter to be unique to each instance. I’ve been trying to set the parameter value within the start function on a script attached to the actual prefab but this doesn’t seem to work.

Anyone have any idea how I might be able to do this?

Here is my code: [code:1e6ep73n]using UnityEngine;
using System.Collections;
using FMOD.Studio;

public class Soundz : MonoBehaviour
{
FMOD.Studio.EventInstance playEvent;
FMOD.Studio.ParameterInstance pitch;

Vector3 Scale;
float ball;
float Yposition;



void Start () 
{
    playEvent = FMOD_StudioSystem.instance.GetEvent("event:/PianoC3");
    Yposition = gameObject.transform.position.y;

    if (Yposition > 11)
    {   
        playEvent.getParameter ("SphereY", out pitch);
        pitch.setValue(0.4f);               
    }

}

void OnCollisionEnter() 
{
    Scale = new Vector3(1, 1, 0);
    ball = gameObject.transform.localScale.magnitude;



    if (ball <= Scale.magnitude)
    {
    playEvent = FMOD_StudioSystem.instance.GetEvent("event:/PianoC3");
    playEvent.start();
    playEvent.release();
    }
    else 
    {
    playEvent = FMOD_StudioSystem.instance.GetEvent("event:/PianoC1");
    playEvent.start();
    playEvent.release();
    }

}

void Update() 
{


}

}[/code:1e6ep73n]

Thanks!

  • You must to post comments
0
0

Take a look at the FMOD_StudioEventEmitter.cs script in the integration, it creates an event instance and positions it based on the gameObject.transform inside Update

[code:6d3m4il8] var attributes = UnityUtil.to3DAttributes (gameObject);
ERRCHECK (evt.set3DAttributes(attributes)); [/code:6d3m4il8]

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.