Ejemplo n.º 1
0
 void Update()
 {
     if ((rb.velocity.magnitude > 1) && playerMovement.IsGrounded())
     {
         SpawnParticle();
     }
 }
Ejemplo n.º 2
0
    private void Update()
    {
        // Don't play wheel sounds when not grounded, or busy playing the jump sound.
        var actualSpeed = rBody.velocity.magnitude;

        var clampedSpeed = Mathfs.Clamp(actualSpeed, minSpeed, maxSpeed);
        var t            = Mathfs.InverseLerp(minSpeed, maxSpeed, clampedSpeed);

        if (!isPlayingJumpSound)
        {
            var volume = Mathfs.Lerp(minVolume, maxVolume, Mathfs.Smooth01(t));
            audioSource.volume = Mathfs.SmoothDamp(audioSource.volume, volume, ref dVolume, 1.0f);
        }
        else if (!playerMovement.IsGrounded())
        {
            audioSource.volume = Mathfs.SmoothDamp(audioSource.volume, airWheelVolume, ref dVolume, 0.1f);
        }

        var pitch = Mathfs.Lerp(minPitch, maxPitch, Mathfs.Smooth01(t));

        audioSource.pitch = Mathfs.SmoothDamp(audioSource.pitch, pitch, ref dPitch, dPitch < 0.0f ? 0.2f : 1.0f);
    }