set3DAttributes() public method

public set3DAttributes ( FMOD.Studio.ATTRIBUTES_3D attributes ) : RESULT
attributes FMOD.Studio.ATTRIBUTES_3D
return RESULT
    // Update is called once per frame
    void Update()
    {
        var feet3DPosition = FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform.position);

        Footsteps.set3DAttributes(feet3DPosition);
        if (Input.GetKeyDown("w") || Input.GetKeyDown("a") || Input.GetKeyDown("s") || Input.GetKeyDown("d"))
        {
            PlayerIsWalking = true;
        }
        if (Input.GetKeyUp("w") || Input.GetKeyUp("a") || Input.GetKeyUp("s") || Input.GetKeyUp("d"))
        {
            PlayerIsWalking = false;
        }

        Footsteps.getPlaybackState(out FootstepsPlaybackState);

        if (PlayerIsWalking && FootstepsPlaybackState != FMOD.Studio.PLAYBACK_STATE.PLAYING && FootstepsPlaybackState != FMOD.Studio.PLAYBACK_STATE.STARTING)
        {
            Footsteps.start();
        }
        else if (!PlayerIsWalking)
        {
            Footsteps.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
        }
    }
示例#2
0
    // Use this for initialization
    public void Init(LevelManager lm, float t)
    {
        _levelManager = lm;
        timeShowing   = t;

        // Event description for creating the scream event instance
        FMOD.Studio.EventDescription screamDescription;
        SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetStudioSoundSystem().getEvent("event:/Scream", out screamDescription));
        SoundSystem.instance.ErrorCheck(screamDescription.createInstance(out _screamInstance));

        // Event description for creating the spawn event instance
        FMOD.Studio.EventDescription spawnDescription;
        SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetStudioSoundSystem().getEvent("event:/HelloCivil", out spawnDescription));
        SoundSystem.instance.ErrorCheck(spawnDescription.createInstance(out _spawnInstance));

        // Set the 3d attributes of this sound depending on this script's owner
        _attributes3D = FMODUnity.RuntimeUtils.To3DAttributes(this.gameObject, this.gameObject.GetComponent <Rigidbody>());
        _screamInstance.set3DAttributes(_attributes3D);
        _spawnInstance.set3DAttributes(_attributes3D);

        // Set the minimum and maximum distances for this sound event
        SoundSystem.instance.ErrorCheck(_screamInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, 3.0f));
        SoundSystem.instance.ErrorCheck(_screamInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, 30.0f));


        // Set the minimum and maximum distances for scream event instance
        SoundSystem.instance.ErrorCheck(_spawnInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, 3.0f));
        SoundSystem.instance.ErrorCheck(_spawnInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, 30.0f));

        _spawnInstance.start();
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        _state = State.IDLE;


        FMOD.Studio.EventDescription walkDescription;
        SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetStudioSoundSystem().getEvent("event:/Steps", out walkDescription));
        SoundSystem.instance.ErrorCheck(walkDescription.createInstance(out _WalkInstance));

        FMOD.Studio.PARAMETER_DESCRIPTION velocityDescription;
        SoundSystem.instance.ErrorCheck(walkDescription.getParameter("Velocidad", out velocityDescription));
        _velocityIndex = velocityDescription.index;

        FMOD.Studio.EventDescription jumpDescription;
        SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetStudioSoundSystem().getEvent("event:/Jump", out jumpDescription));
        SoundSystem.instance.ErrorCheck(jumpDescription.createInstance(out _jumpInstance));

        FMOD.Studio.EventDescription shootDescription;
        SoundSystem.instance.ErrorCheck(SoundSystem.instance.GetStudioSoundSystem().getEvent("event:/Shot", out shootDescription));
        SoundSystem.instance.ErrorCheck(shootDescription.createInstance(out _shootInstance));
        //SoundSystem.instance.ErrorCheck(_shootInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, 3.0f));
        //SoundSystem.instance.ErrorCheck(_shootInstance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, 200.0f));

        _attributes3D = FMODUnity.RuntimeUtils.To3DAttributes(this.gameObject, this.gameObject.GetComponent <Rigidbody>());
        _jumpInstance.set3DAttributes(_attributes3D);
        _WalkInstance.set3DAttributes(_attributes3D);
        _shootInstance.set3DAttributes(_attributes3D);
    }
示例#4
0
 //set the 3D attributes of the audio event, checking for a rigidbody in the process
 private void Set3DAttributes()
 {
     if (rigidBody == null)
     {
         sound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform));
         return;
     }
     sound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform, rigidBody));
 }
示例#5
0
    //cat/milk puzzle, currently the 'first' puzzle
    public void emitLightningForCatPuzzle()
    {
        gameObject.transform.position = new Vector3(2.75f, 20.4f, -5.0f);
        var lightningPosition = FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform.position);

        baseLightningSound.set3DAttributes(lightningPosition);
        baseLightningSound.start();
        StartCoroutine(DelayLightningStrikeForCatPuzzle());
        StartCoroutine(DelayAppearanceOfCatPuzzle());
    }
    // Start is called before the first frame update
    void Start()
    {
        Footsteps = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/Footsteps");
        var feet3DPosition = FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform.position);

        Footsteps.set3DAttributes(feet3DPosition);
    }
示例#7
0
 private static void Set3DAttributes(FMOD.Studio.EventInstance evt, ATTRIBUTES_3D attributes)
 {
     if (evt != null && evt.isValid())
     {
         UnityUtil.ERRCHECK(evt.set3DAttributes(attributes));
     }
 }
示例#8
0
 // Use this for initialization
 void Start()
 {
     SpeechLoop = FMODUnity.RuntimeManager.CreateInstance(SpeechEvent);
     SpeechLoop.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     SpeechLoop.start();
     Debug.Log("Playing speech loop sound", gameObject);
 }
 public void PlayFootstep()
 {
     footstep = FMODUnity.RuntimeManager.CreateInstance("event:/Footstep");
     footstep.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     footstep.start();
     footstep.release();
 }
示例#10
0
 public void PlayCharacterLand()
 {
     land = FMODUnity.RuntimeManager.CreateInstance("event:/CharacterLand");
     land.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     land.start();
     land.release();
 }
示例#11
0
文件: Bee.cs 项目: Waevka/SoundScene
 // Use this for initialization
 void Start()
 {
     BeeLoop = FMODUnity.RuntimeManager.CreateInstance(BeeEvent);
     BeeLoop.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(beeModel));
     StartCoroutine(BeeDelay(beeDelay));
     Debug.Log("Playing bee sound", gameObject);
 }
示例#12
0
	// Use this for initialization
	void Start()
	{
		soundNameMap = new Dictionary<string, string>();
		FillMap("boil", boilSoundNamePrefix, 3);
		FillMap("fry", frySoundNamePrefix, 3);
		FillMap("chop", chopSoundNamePrefix, 3);
		FillMap("bin", binSoundNamePrefix, 3);
		FillMap("footstep", footstepSoundNamePrefix, 6);
		FillMap("pick", pickSoundNamePrefix, 3);

		FillMap("complete", completeSoundName);
		FillMap("dishDone", dishDoneSoundName);
		FillMap("drop", dropSoundName);
		FillMap("lose", loseSoundName);
		FillMap("bell", bellSoundName);

		FillMap("demonTalk", demonTalkSoundName);
		FillMap("ritualSuccess", ritualSuccessSoundName);
		FillMap("ritualFailure", ritualFailureSoundName);
		FillMap("fire", fireSoundName);
		FillMap("smokeAlarm", smokeAlarmSoundName);

		currentSounds = new List<EventInstance>();
		_musicEvent = FMODUnity.RuntimeManager.CreateInstance(musicEventName);
		_musicEvent.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Camera.allCameras[0].transform.position));
	}
    // Update is called once per frame
    void Update()
    {
        var feet3DPosition = FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform.position);

        bathroomCutsceneBathroomFootsteps.set3DAttributes(feet3DPosition);
        bathroomCutsceneGroundFootsteps.set3DAttributes(feet3DPosition);
    }
示例#14
0
文件: Test.cs 项目: slb1988/FmodDemo
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S))
        {
            if (instance != null)
            {
                //instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
                instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                instance.release();
            }

            instance = FMOD_StudioSystem.instance.GetEvent(path);
            if (instance != null)
            {
                var attributes = FMOD.Studio.UnityUtil.to3DAttributes(position);
                ERRCHECK(instance.set3DAttributes(attributes));
                ERRCHECK(instance.setVolume(volume));
                instance.start();
            }
        }
        if (Input.GetKeyDown(KeyCode.J))
        {
            instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
            instance.release();
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
            instance.release();
        }
    }
示例#15
0
    void Update()
    {
        //--------------------------------------------------------------------
        // 8: This shows how to manually update the instance of a 3D event so
        //    it has the position and velocity of it's game object. (5) Show
        //    how this can be done automatically.
        //--------------------------------------------------------------------
        playerState.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, cachedRigidBody));

        //--------------------------------------------------------------------
        // 9: This shows how to update a parameter of an instance every frame
        //--------------------------------------------------------------------
        playerState.setParameterByID(healthParameterId, (float)health);

        //--------------------------------------------------------------------
        // 10: This shows how to query the playback state of an event instance.
        //     This can be useful when playing a one shot to take action
        //     when it finishes. Other playback states can be checked including
        //     Sustaining and Fading-Out.
        //--------------------------------------------------------------------
        if (playerIntro.isValid())
        {
            FMOD.Studio.PLAYBACK_STATE playbackState;
            playerIntro.getPlaybackState(out playbackState);
            if (playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED)
            {
                playerIntro.release();
                playerIntro.clearHandle();
                SendMessage("PlayerIntroFinished");
            }
        }
    }
示例#16
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButton("Fire2"))
        {
            if (this.transform.parent == player)
            {
                raiseSpear();
            }
            else if (this.transform.parent == playerCam)
            {
                if (Input.GetButton("Fire1"))
                {
                    throwSpear();
                }
            }
        }
        else if (this.transform.parent == playerCam)
        {
            lowerSpear();
        }
        else if (this.transform.parent != playerCam && this.transform.parent != player && Input.GetButton("Fire1"))
        {
            pickUpSpear();
        }

        raiseSpearSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
    }
示例#17
0
    // Use this for initialization
    private void Start()
    {
        m_fSoundRadius = GetComponent <FMODUnity.StudioEventEmitter>().OverrideMaxDistance;       //Use the FMOD events distance

        m_fmSoundEventInstance = FMODUnity.RuntimeManager.CreateInstance(m_sSoundToPlay);         //Create a sound instance that we can control
        m_fmSoundEventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform)); //Make the sound here
        m_fmSoundEventInstance.start();                                                           //Start the sound
        m_fmSoundEventInstance.release();

        Collider[] cTargetsInViewRadius = Physics.OverlapSphere(transform.position, m_fSoundRadius, m_GuardAlertMask);//Get all guards in radius

        foreach (Collider cCurrentTarget in cTargetsInViewRadius)
        {
            CS_GuardHearing cGuardRef = cCurrentTarget.GetComponent <CS_GuardHearing>();
            if (cGuardRef != null)
            {
                if (a_bRadio)
                {
                    cGuardRef.AlertHearRadio(transform);
                }
                else
                {
                    cGuardRef.AlertHearOtherSound(transform);
                }
            }
        }
    }
示例#18
0
    // function called directly from animation events when
    // player animation steps(must be set up in each animation used)
    private void PlayStep()
    {
        if (SceneManagerFTTE.fmodEnable)
        {
            float velocity = GetComponent <Rigidbody>().velocity.magnitude;
            Footstep = FMODUnity.RuntimeManager.CreateInstance(FootstepEvent);
            Footstep.setParameterByName("Velocity", velocity);
            Footstep.setParameterByName("CharacterType", characterType);
            Footstep.setParameterByName("Material", material);

            Footstep.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));

            Footstep.start();
            Footstep.release();
        }

        // pick & play a random footstep sound from the array,
        // excluding sound at index 0
        //int n = Random.Range(1, TPC.m_FootstepSounds.Length);
        //TPC.m_AudioSource.clip = TPC.m_FootstepSounds[n];
        //TPC.m_AudioSource.PlayOneShot(TPC.m_AudioSource.clip);
        //// move picked sound to index 0 so it's not picked next time
        //TPC.m_FootstepSounds[n] = TPC.m_FootstepSounds[0];
        //TPC.m_FootstepSounds[0] = TPC.m_AudioSource.clip;
    }
示例#19
0
 // Use this for initialization
 void Start()
 {
     sfxInstance = FMODUnity.RuntimeManager.CreateInstance(Managers.AudioMan.towerBuild);
     sfxInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     sfxInstance.start();
     weaponTransform = transform.Find("Weapon");
 }
示例#20
0
    private void Respawn()
    {
        IsDie = false;

        if (this.destroyAllPillierwhenIDie)
        {
            foreach (var pillier in this.myPillier)
            {
                //BoltNetwork.Destroy(pillier.gameObject);
                pillier.ActiveDestroy();
            }
            this.myPillier = new List <Pillier>();

            foreach (var seedOk in this.seedReadyImagesViseur)
            {
                seedOk.color = this.colorReady;
            }

            foreach (var seedOk in this.seedReadyUI)
            {
                seedOk.color = this.colorReady;
            }

            this.maskPanel.sizeDelta = new Vector2(this.maskPanel.rect.width, this.maxHeightMask);

            this.currentPillier            = 0;
            this.seedReadyImage.color      = Color.green;
            this.currentCooldownLaunchSeed = Time.time + 1;
            this.IsCooldown = false;
        }

        if (entity.IsOwner)
        {
            state.MyColor = lastColor;
            respawnAudioMe.start();
        }
        else
        {
            respawnAudioOther.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform.position));
            respawnAudioOther.start();
        }

        this.lastGuardianWhoHitMe = null;
        var spawnPosition = RespawnPoint();

        this.health = this.lastHealth;

        this.transform.position = spawnPosition;

        this.scoreAdditionel = 0;
        StopAllCoroutines();

        GameObject go = Instantiate(respawnParticulePrefab, this.feetPosition.position, Quaternion.identity);

        go.transform.SetParent(this.transform);
        go.transform.rotation = Quaternion.AngleAxis(-90, Vector3.right);
        Destroy(go, 2.5f);

        //respawnParticulePrefab
    }
 // Start is called before the first frame update
 void Start()
 {
     instance = FMODUnity.RuntimeManager.CreateInstance("event:/LightAudio");
     instance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     //volume = 1;
     lightActive = false;
 }
示例#22
0
 void PlayFootsteps(string path)
 {
     FMOD.Studio.EventInstance Footsteps = FMODUnity.RuntimeManager.CreateInstance(path);
     Footsteps.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     Footsteps.start();
     Footsteps.release();
 }
示例#23
0
    virtual public void Damage(Enemy enemy)
    {
        if (enemy.gameObject.activeInHierarchy)
        {
            if (attackKill)
            {
                // TODO: FreeParallax use the enemy object reference.
                // Needs review this implementation

                // Destroy(enemy.gameObject);
                //Plays sound

                enemySound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(enemy.gameObject));
                enemySound.start();
                enemySound.release();


                enemy.gameObject.SetActive(false);
                if (OnKillEnemy != null)
                {
                    OnKillEnemy(1);
                }
                rewardsAmount += 1;
            }
            else
            {
                Debug.LogError("Only one attack kill is not implemented yet. Please, mark attackKill inspector property");
            }
        }
    }
示例#24
0
 void PlayDeath(string path)
 {
     FMOD.Studio.EventInstance Death = FMODUnity.RuntimeManager.CreateInstance(path);
     Death.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     Death.start();
     Death.release();
 }
示例#25
0
    void BushSound(bool isMoving)
    {
        if (isMoving && !isHardPlaying)
        {
            hardNoise = FMODUnity.RuntimeManager.CreateInstance("event:/Outside/BushNoiseHard");
            hardNoise.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
            hardNoise.start();
            hardNoise.release();
            isHardPlaying = true;
        }
        else if (!isMoving)
        {
            hardNoise.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
            isHardPlaying = false;
        }

        if (MouseMovment() && !isSoftPlaying)
        {
            softNoise = FMODUnity.RuntimeManager.CreateInstance("event:/Outside/BushNoiseSoft");
            softNoise.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
            softNoise.start();
            softNoise.release();
            isSoftPlaying = true;
        }
        else if (!MouseMovment())
        {
            softNoise.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
            isSoftPlaying = false;
        }
    }
示例#26
0
文件: Test.cs 项目: slb1988/FmodDemo
    void OnMouseDown()
    {
        if (playFlag)
        {
            playFlag = false;
            instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
            instance.release();
            instance = null;
        }
        else
        {
            if (instance != null)
            {
                //instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
                instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
                instance.release();
            }

            instance = FMOD_StudioSystem.instance.GetEvent(path);
            if (instance != null)
            {
                var attributes = FMOD.Studio.UnityUtil.to3DAttributes(position);
                ERRCHECK(instance.set3DAttributes(attributes));
                ERRCHECK(instance.setVolume(volume));
                instance.setParameterValue("Surface", SurfaceValue);
                instance.start();
            }

            playFlag = true;
        }
    }
示例#27
0
    public void Play()
    {
        if (!instance.isValid())
        {
            //Debug.Log("Play FMOD Emitter. Event: " + Event);
            instance = FMODUnity.RuntimeManager.CreateInstance(Event);

            // Only want to update if we need to set 3D attributes
            if (is3D)
            {
                Rigidbody2D rigidBody2D = GetComponent <Rigidbody2D>();
                Transform   transform   = GetComponent <Transform>();
                instance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, rigidBody2D));
                FMODUnity.RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D);
            }

            /*
             * if (is3D && OverrideAttenuation)
             * {
             *  instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance);
             *  instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance);
             * }
             */

            instance.start();
        }
    }
示例#28
0
 // Use this for initialization
 void Start()
 {
     HelicopterSound = FMODUnity.RuntimeManager.CreateInstance(HelicopterEvent);
     HelicopterSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(helicopterModel));
     HelicopterSound.start();
     Debug.Log("Playing helicopter sound", gameObject);
 }
示例#29
0
    void Update()
    {
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");


        fmodWalkInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
        if (Mathf.Abs(move.x) >= 0.01f || Mathf.Abs(move.z) >= 0.01f)
        {
            if (!isWalking)
            {
                fmodWalkInstance.setParameterByName("Movement", 1, false);
                isWalking = true;
            }
        }
        else if (isWalking)
        {
            fmodWalkInstance.setParameterByName("Movement", 0, false);
            isWalking = false;
        }


        position = _rigidbody.position;
        move     = new Vector3(horizontal, 0, vertical);

        position = position + move * speed * Time.deltaTime;
        _rigidbody.MovePosition(position);

        if (Input.GetButtonDown("Jump"))
        {
            _rigidbody.AddForce(jump, ForceMode.VelocityChange);
            FMODUnity.RuntimeManager.PlayOneShot(fmodJumpEvent);
        }
    }
    void PlaySound()
    {
        //Defaults
        m_Water = 0.0f;
        m_Dirt  = 0.0f;
        m_Sand  = 0.0f;
        m_Wood  = 0.0f;


        if (m_EventPath != null)
        {
            FMOD.Studio.EventInstance e = FMODUnity.RuntimeManager.CreateInstance(m_EventPath);
            e.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform.position));



            SetParameter(e, "Wood", m_Wood);
            SetParameter(e, "Dirt", m_Dirt);
            SetParameter(e, "Sand", m_Sand);
            SetParameter(e, "Water", m_Water);

            e.start();
            e.release();    //Release each event instance immediately, there are fire and forget, one-shot instances.
        }
    }
示例#31
0
 // Update is called once per frame
 void Update()
 {
     if (effectPlaying)
     {
         Ringtone.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     }
 }
示例#32
0
 // Use this for initialization
 void Start()
 {
     OrganLoop = FMODUnity.RuntimeManager.CreateInstance(ChurchEvent);
     OrganLoop.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
     OrganLoop.start();
     print("Playing church organ sound");
 }
    protected void PlayEvent()
    {
        if (!string.IsNullOrEmpty(eventName))
        {
            eventInstance = FMODUnity.RuntimeManager.CreateInstance(eventName);
            // Only attach to object if the game is actually playing, not auditioning.
            if (Application.isPlaying && TrackTargetObject)
            {
                Rigidbody rb = TrackTargetObject.GetComponent <Rigidbody>();
                if (rb)
                {
                    FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, rb);
                }
                else
                {
                    FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, TrackTargetObject.GetComponent <Rigidbody2D>());
                }
            }
            else
            {
                eventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero));
            }

            foreach (var param in parameters)
            {
                eventInstance.setParameterByID(param.ID, param.Value);
            }

            eventInstance.start();
        }
    }
示例#34
0
 void Start()
 {
     currentActiveSwitches = 0;
     prevActiveSwitches = 0;
     openPosition = new Vector3(transform.position.x, transform.position.y + raiseHeight, transform.position.z);
     closedPosition = transform.position;
     doorSlideAudio = FMOD_StudioSystem.instance.GetEvent("event:/sfx/environment/puzzlePiece/slidingStoneDoor");
     var attributes = FMOD.Studio.UnityUtil.to3DAttributes(this.transform.position);
     doorSlideAudio.set3DAttributes(attributes);
 }
        void Start()
        {
            // Set up and start ambience audio
            ambientSoundEvent = FMOD_StudioSystem.instance.GetEvent("event:/ambience/wind");
            var attributes = FMOD.Studio.UnityUtil.to3DAttributes(transform.position);
            ambientSoundEvent.set3DAttributes(attributes);
            ambientSoundEvent.start();

            // Set up reverb zone for the cave area
            caveVerbZone = GameObject.Find("verbZone");
        }
示例#36
0
    public void Interaction_PowerBox()
    {
        // Check if character is in Interaction Distance
        if (Vector2.Distance(pos_powerBox.position, PlatformerCharacter2D.m_InteractionCheck.position) <= interactionDistance)
        {
            inRange = true;
        //    Debug.Log("Interactable");
        }
        else if (Vector2.Distance(pos_powerBox.position, PlatformerCharacter2D.m_InteractionCheck.position) > interactionDistance)
        {
            inRange = false;
        //    Debug.Log("Not Interactable");
        }
        if (inRange == true && interaction == true && interacted == false && Power.flicker == true)
        {
           // play repair sound
           FMODUnity.RuntimeManager.PlayOneShot("event:/repair", gameObject.transform.position);

           //Event
           interacted = true;
           box_anim.SetBool("powerOn", true);
           Debug.Log("Interacted");

           //Turning On Lanterns
           GameObject lantern1 = GameObject.Find("Night-Environment-Assets-Lantern");
           Power lanternOn1 = (Power)lantern1.GetComponent(typeof(Power));
           lanternOn1.PowerOn(true);
           //2
           GameObject lantern2 = GameObject.Find("Night-Environment-Assets-Lantern (3)");
            Power lanternOn2 = (Power)lantern2.GetComponent(typeof(Power));
           lanternOn2.PowerOn(true);
           //3
           GameObject lantern3 = GameObject.Find("Night-Environment-Assets-Lantern (4)");
            Power lanternOn3 = (Power)lantern3.GetComponent(typeof(Power));
           lanternOn3.PowerOn(true);
           //House
           GameObject house = GameObject.Find("Night-Environment-Assets-House");
           Power houseOn = (Power)house.GetComponent(typeof(Power));
           houseOn.PowerOn(true);
            House house1 = (House)house.GetComponent (typeof(House));
            house1.disableCollision();

            //Tower
            GameObject tower = GameObject.Find("Night-Environment-Assets-Tower");
            Tower towerOn = (Tower)tower.GetComponent (typeof(Tower));
            towerOn.PowerOn (true);

           // play lamp buzz sound
           lampBuzz = FMODUnity.RuntimeManager.CreateInstance("event:/lamp_buzz");
           lampBuzz.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform));
           lampBuzz.start();
        }
    }
    IEnumerator PlayFlute(EventInstance fluteAudio)
    {
        // set the position of the sound effect to be the player's position
        var attributes = FMOD.Studio.UnityUtil.to3DAttributes(transform.position);
        fluteAudio.set3DAttributes(attributes);
        fluteAudio.start();

        characterParticles.Play(true);

        float start = Time.time;
        float time = start;

        while (time <= start + 5f)
        {
            // update the position of the sound as the player moves
            attributes = FMOD.Studio.UnityUtil.to3DAttributes(transform.position);
            fluteAudio.set3DAttributes(attributes);

            time += Time.deltaTime;
            yield return null;
        }
    }