public void StartEvent(string key, AudioChannel channel = AudioChannel.Action, bool stopPre = true, string para = "", float value = 0f) { FMOD_StudioEventEmitter emitter = this.GetEmitter(channel); if (stopPre) { emitter.OnDestroy(); } if (!string.IsNullOrEmpty(key)) { emitter.path = key; } emitter.CacheEventInstance(); this.SetParamValue(channel, para, value); if (this._3dPos != Vector3.zero) { emitter.Update3DAttributes(this._3dPos); this._3dPos = Vector3.zero; } emitter.StartEvent(); }
void OnCollisionEnter(Collision coll) { /*Vector3 posDiff = coll.transform.position - transform.position; * transform.position += posDiff.normalized * 20.0f;*/ // Debug.Log (gameObject.name + " BUMPED OFF "+ coll.gameObject.name); Vector3 avgNormal = Vector3.zero; foreach (ContactPoint contact in coll.contacts) { // Debug.DrawRay(contact.point, contact.normal, Color.white); avgNormal += contact.normal; } transform.position += avgNormal.normalized * 15.0f; if (fmodSource) { if (PlayerControl.instance.isDead == false) { fmodSource.StartEvent(); } } else { SoundCenter.instance.PlayClipOn( SoundCenter.instance.bumpSound, transform.position, 1.0f, (GetComponent <PlayerControl>() ? PlayerControl.instance.transform : null)); } Shootable shootableScript = GetComponent <Shootable>(); if (shootableScript && shootableScript.healthLimit > 0) { shootableScript.ExplodeThis(); } }