void FixedUpdate() { if (BuffManager.playerMovementDebuff) { BuffManager.playerMovementDebuff = false; movementSpeed = movementSpeed * 0.75f; BuffManager.debuffCounter += 1; } if (BuffManager.movementBuff) { BuffManager.movementBuff = false; movementSpeed = movementSpeed * 1.2f; BuffManager.buffCounter += 1; } float moveVertical = Input.GetAxis("Vertical"); float moveHorizontal = Input.GetAxis("Horizontal"); rigidBody.velocity = new Vector3(moveHorizontal * movementSpeed, moveVertical * movementSpeed, 0); if (rigidBody.velocity.x == 0 && rigidBody.velocity.y == 0) { audioSrc.FadeOut(2f); } else { audioSrc.volume = 1f; audioSrc.mute = false; } }
public void PassToCombatTrack() { combatTrack.FadeIn(.5f, 1f); idleTrack.FadeOut(.5f); combatTrack.Play(); PlayingIdleTrack = false; PlayingCombatTrack = true; }
private void StopSound(AudioSource audioSource, float fadeDuration = 0f) { if (audioSource == null) { return; } audioSource.FadeOut(fadeDuration, this); }
private void StopWithFadeOut() { //if (rocketSound.isPlaying) //{ rocketSound.FadeOut(0.1f); //rocketSound.Stop(); rocketSound.loop = false; //} }
/// <summary> /// Stop the current track. /// Will always be run on active instance, so it is safe to use in UnityEvents even if inactive. /// </summary> public void Stop() { if (inst != this) { inst.Stop(); return; } if (!currentSource) { return; } if (fadeOut) { currentSource.FadeOut(); } else { currentSource.Stop(); } currentSource = null; }
/// <summary> /// BGMのフェードアウト /// </summary> /// <param name="fadeTime">fade time</param> public void FadeOutBGM(float fadeTime, float endVolume = 0.0f) { StartCoroutine(_bgmSource.FadeOut(fadeTime, endVolume)); }
private void Update() { if (raycastAimPlaneTransform != null) { raycastAimPlaneTransform.position = transform.position + initialRaycastAimPlanePosOffset; } if (!waitingForFallToGroundCheck) { CheckForGround(); } else { if (rb.velocity.y < 0.0f) { waitingForFallToGroundCheck = false; isJumping = false; } } if (isGrounded) { if (!rollingAudioSource.FadeOutIsActive()) { float volumeInterpValue = Mathf.Clamp( rb.velocity.magnitude / maxSpeedForRollVolume, 0.0f, 1.0f); rollingAudioSource.volume = Mathf.Lerp(0.0f, 0.3f, volumeInterpValue); if (!rollingAudioSource.isPlaying) { rollingAudioSource.Play(); } } } else { if (rollingAudioSource.isPlaying && !rollingAudioSource.FadeOutIsActive()) { rollingAudioSource.FadeOut(); } } /*if (inputIsEnabled) { * if (isGrounded) { * if (Input.GetButtonDown("Jump")) { * GeneralAudioPool.Instance.PlaySound(jumpAudioClip, 0.25f, Random.Range(0.9f, 1.1f)); * * rb.AddForce(Vector3.up * initialJumpLaunchForce, ForceMode.Impulse); * waitingForFallToGroundCheck = true; * isGrounded = false; * * jumpActiveTimer = 0.0f; * isJumping = true; * } * } * if (Input.GetButtonUp("Jump")) { * isJumping = false; * } * }*/ if (transform.position.y < yPosResetCutoff) { transform.position = initialPos; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; } if (Application.isEditor && !sceneIsLoading && Input.GetKeyDown(KeyCode.BackQuote)) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); sceneIsLoading = true; } }
public static IEnumerator FadeOutAsCoroutine(this AudioSource self, float duration) { self.FadeOut(duration); yield return(new WaitForSeconds(duration)); }