Answered
0
0

Hello,

I am trying to get a human projectile to instantiate a sound based on 3 variable ranges. I seem to have the variables updating and changing sound correctly, but the 3D information is not being applied. the sound is in 2D and does not play consistently. It seems quite hard to find up to date information about the scripting API and unity implementation. Here is the code I am using:

public static FMOD.Studio.EventInstance gunfireEvent;
public static FMOD.Studio.ParameterInstance fireSpeed;
public string fire = "event:/Gunfire"; 
private FMOD.ATTRIBUTES_3D Attributes;
float paramValue;

// Use this for initialization
void Start () {

    var rigidBody = GetComponent<Rigidbody>();
    var transform = GetComponent<Transform>();

    gunfireEvent = FMODUnity.RuntimeManager.CreateInstance (FireBullet);
    Attributes = FMODUnity.RuntimeUtils.To3DAttributes (gameObject,rigidBody);
    FMODUnity.RuntimeManager.AttachInstanceToGameObject(gunfireEvent, transform, rigidBody);
    gunfireEvent.getParameter ("fireSpeed", out fireSpeed);
            paramValue = NadeShot.power;
}

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

{
    gunfireEvent.set3DAttributes (Attributes);
    fireSpeed.setValue (paramValue);
    gunfireEvent.start ();


    Debug.Log (paramValue);
}
  • You must to post comments
Best Answer
0
0

Using AttachInstanceToGameObject will internally call set3DAttributes so you don’t need to.
Make sure the event is setup as 3D in Studio.

There is plenty of info in our documentation. Otherwise you can take a look at our example scripts that come with the integration.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.