FMOD 3D PANNER


(juan montoya) #1

hello, when i erase the 3d the sound is ok, but when i put tthe 3d panner, there is no sound, why?

run the code and the sound is ok! but…

no sound! when the player moves until the 3d space :frowning:
even when the enemy is not moving. and whe i assign a built in distance parameter.


(Joseph Harvey) #2

By default, our unity integration attaches the listener to the camera. Your game seems to use third-person perspective; If you want the audibility of events to be based on the player’s position, you need to attach the listener to the player. Have you done this?


(juan montoya) #3

Yes! that is the solution! it works. thank you Joseph Harvey.

but i have another problem, that work if a have the sound in a Studio Event Emitter, but when i use the script something missing, maybe activate the 3d panner in the script, but how?

the script

using UnityEngine;
using System.Collections;

public class EnemyMovement : MonoBehaviour
{
Transform player;
PlayerHealth playerHealth;
EnemyHealth enemyHealth;
NavMeshAgent nav;

[FMODUnity.EventRef]
public string Playerstate2 = "event:/Music";

void Awake ()
{
    player = GameObject.FindGameObjectWithTag ("Player").transform;
    playerHealth = player.GetComponent <PlayerHealth> ();
    enemyHealth = GetComponent <EnemyHealth> ();
    nav = GetComponent <NavMeshAgent> ();
}


void Update ()
{

	FMODUnity.RuntimeManager.PlayOneShot (Playerstate2 );
    if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
    {
        nav.SetDestination (player.position);
    }
    else
    {
        nav.enabled = false;
    }
}

}

if i use the 3d panner not work , only in the studio event emmiter. if i erase the 3d panner doesn´t sound.


(Nicholas Wilcox) #4

Use

FMODUnity.RuntimeManager.PlayOneShot(Playerstate2, transform.position);

to play the sound at the objects current location.

Use

FMODUnity.RuntimeManager.PlayOneShot(Playerstate2, gameObject);

to have the sound follow the game object position for the duration of the event.