void Update() { if (cycleForce == null) { return; } if (thrustAmount.val > 0) { cycleForce.forceQuickness = Remap(thrustAmount.val, 0.0f, 1.0f, 0.7f, 6.0f); cycleForce.forceFactor = Remap(thrustAmount.val, 0.0f, 1.0f, 500, 600); cycleForce.forceDuration = Remap(thrustAmount.val, 0.0f, 1.0f, 0.9f, 1.0f); } else { cycleForce.forceQuickness = 0.0f; } if (grindAmount.val > 0) { cycleForce.torqueFactor = Remap(grindAmount.val, 0.0f, 1.0f, 0.0f, 120.0f); cycleForce.torqueQuickness = Remap(grindAmount.val, 0.0f, 1.0f, 0.7f, 6.0f); } else { cycleForce.torqueQuickness = 0.0f; } cycleForce.period = Remap(Mathf.Clamp01(thrustAmount.val + grindAmount.val), 0.0f, 1.0f, 2.2f, 0.3f); if (audioSource != null) { if (Time.fixedTime > nextSFXTime && (grindAmount.val > 0 || thrustAmount.val > 0)) { if (cycleForce.forceQuickness > 4.4f) { if (skinSlapClip != null) { audioSource.pitch = UnityEngine.Random.Range(0.95f, 1.05f); audioSource.PlayNow(skinSlapClip); } } else if (cycleForce.forceQuickness > 0.5f || (cycleForce.torqueFactor > 1.0f && cycleForce.appliedTorque.magnitude >= 10.0f)) { if (grindClip != null) { audioSource.pitch = UnityEngine.Random.Range(0.95f, 1.05f); audioSource.PlayNow(grindClip); } } nextSFXTime = Time.fixedTime + cycleForce.period; } } }
public void PlayAudio(NamedAudioClip clip) { if (clip != null) { headAudioSource.PlayNow(clip); } }
/** * Play the assigned audio clip with optional "if clear" param. */ public void Play(AudioSourceControl receiver = null, bool ifClear = false, bool clearQueue = false) { if (SourceClip == null) { return; } if ((UnityEngine.Object)receiver != (UnityEngine.Object)null) { Receiver = receiver; } if (ifClear) { Receiver.PlayIfClear(SourceClip); } else { if (clearQueue) { Receiver.PlayNowClearQueue(SourceClip); } else { Receiver.PlayNow(SourceClip); } } }
protected override void DoSet(bool paused) { base.DoSet(paused); if (inDelay_) { return; } if (newClip_) { switch (playType_) { case PlayIfClear: source_.PlayIfClear(currentClip_); break; case PlayNow: // fall-through default: source_.PlayNow(currentClip_); break; } if (source_.playingClip == currentClip_) { source_.audioSource.time = 0; newClip_ = false; } } }
public void PlayExpression(ExpressionAnimation animation) { ExpressionAnimation lastAnimation = currentAnimation; currentAnimation = animation; currentAnimation.Start(); if (animation.nac != null) { headAudioSource.PlayNow(animation.nac); } if (lastAnimation != null && currentAnimation != null && lastAnimation != currentAnimation) { transitionAnimation = new ExpressionAnimation(morphControl, lastAnimation, currentAnimation); transitionAnimation.StartFadeOut(); } }
public override void Init() { try { AudioSourceControl source = containingAtom.GetStorableByID("AudioSource") as AudioSourceControl; if (source == null) { SuperController.LogError("This plugin only works on AudioSource"); return; } clipCount = new JSONStorableFloat("clipCount", 0, 0, 100, false, false); RegisterFloat(clipCount); JSONStorableAction audioClipAction = new JSONStorableAction("Play Random", () => { if (clips.Count == 0) { return; } source.PlayNow(clips[UnityEngine.Random.Range(0, clips.Count)]); }); CreateButton("Play Random").button.onClick.AddListener(() => { audioClipAction.actionCallback(); }); RegisterAction(audioClipAction); UIDynamicButton addClipButton = CreateButton("Add Clip"); addClipButton.buttonColor = new Color(0, 1, 0); addClipButton.button.onClick.AddListener(() => { BuildClipUI(clips.Count); }); //GetStringParamNames().ForEach((s) => Debug.Log(s)); //Debug.Log(GetStringChooserParamNames().Count); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
public void StartBreathing(Breathe breath, float duration) { if (panting == null) { Debug.Log("panting"); return; } if (breathingIdle == null) { Debug.Log("idle"); return; } if (breathingActive == null) { Debug.Log("active"); return; } if (breath.breath > 0.6f) { panting.TriggerFacial(duration); headAudioSource.PlayNow(panting.audioClip); } else if (breath.breath > 0.3f) { breathingActive.TriggerFacial(duration); headAudioSource.PlayNow(breathingActive.audioClip); } else { breathingIdle.TriggerFacial(duration); headAudioSource.PlayNow(breathingIdle.audioClip); } foreach (string key in facialKeys) { Facial f = facial[key]; f.shouldFade = true; } }