/// <summary>
    /// 音の更新
    /// 回転数に応じて音量ピッチを変更する
    /// </summary>
    /// <param name="carSoundParam"></param>
    public override void SoundUpdate(CarSoundParam carSoundParam)
    {
        if (!mIsPlay)
        {
            return;
        }
        if (carSoundParam.RpmInput < InRPM || carSoundParam.RpmInput > OutRPM)
        {
            mSource.volume = Mathf.Clamp01(Mathf.Lerp(mSource.volume, 0f, 0.8f));
            mSource.pitch  = Mathf.Lerp(mSource.pitch, 1f, 0.5f);
            return;
        }
        var rpmRate = (carSoundParam.RpmInput - InRPM) / (OutRPM - InRPM);

        if (rpmRate >= 1f)
        {
            rpmRate = 1f;
        }
        else if (rpmRate <= 0f)
        {
            rpmRate = 0f;
        }
        var ratio = VolumeCurve.Evaluate(rpmRate);

        mSource.volume = ratio;
        ratio          = PitchCurve.Evaluate(rpmRate);
        mSource.pitch  = 1f + ratio;
    }
 public override void SoundUpdate(CarSoundParam carSoundParam)
 {
     if (!mIsPlay)
     {
         return;
     }
     mSource.volume = VolumeCurve.Evaluate(carSoundParam.VelocityInput * WindRushVolumeRate);
     mSource.pitch  = 1f + PitchCurve.Evaluate(carSoundParam.VelocityInput * WindRushPitchRate);
 }
Beispiel #3
0
 public override void SoundUpdate(CarSoundParam carSoundParam)
 {
     if (!mIsPlay)
     {
         return;
     }
     mSource.volume = VolumeCurve.Evaluate(carSoundParam.BrakeInput);
     mSource.pitch  = PitchCurve.Evaluate(carSoundParam.BrakeInput);
 }
Beispiel #4
0
    public override void SoundUpdate(CarSoundParam carSoundParam)
    {
        if (!mIsPlay)
        {
            return;
        }
        var angle = Vector3.Angle(mTransform.forward, carSoundParam.PreVelocity);
        var rate  = Mathf.Clamp01(angle / MaxSlipAngle);

        mSource.volume = VolumeCurve.Evaluate(rate);
        mSource.pitch  = PitchCurve.Evaluate(rate);
    }
Beispiel #5
0
 public override void SoundUpdate(CarSoundParam carSoundParam)
 {
     if (!mIsPlay)
     {
         return;
     }
     if (carSoundParam.HitVelocity <= 0f)
     {
         mSource.volume = 0f;
         mSource.pitch  = 1f;
         if (mIsPlay)
         {
             Stop();
         }
         return;
     }
     mSource.volume = VolumeCurve.Evaluate(Mathf.Abs(carSoundParam.VelocityInput) * CollisionVolumeRate);
     mSource.pitch  = PitchCurve.Evaluate(Mathf.Abs(carSoundParam.VelocityInput) * CollisionPitchRate);
     if (!mIsPlay)
     {
         Play();
     }
 }