---
tags:
    - "Positive"
    - "Negative"
    - "Symbol"
---

# Exponential Decay

[Math](index.md) / **Exponential Decay**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Interpolates a rotation value from Current to Target over time

!!! note
    Useful Decay values range between 1 and 25

!!! note
    Learn more: https://www.youtube.com/watch?v=LSNQuFEDOyQ

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Exponential Decay")]
    [Category("Math/Exponential Decay")]
    
    [Description("Interpolates a rotation value from Current to Target over time")]
    [Image(typeof(IconSnailCat), ColorTheme.Type.Yellow)]
    
    [Keywords("Positive", "Negative", "Symbol")]
    
    [Note("Useful Decay values range between 1 and 25")]
    [Note("Learn more: https://www.youtube.com/watch?v=LSNQuFEDOyQ")]
    
    [Serializable]
    public class TypeQuaternionMathExponentialDecay : TypeQuaternion
    {
        [SerializeField] private GetQuaternion m_Current = new GetQuaternion();
        [SerializeField] private GetQuaternion m_Target = new GetQuaternion();
        
        [SerializeField] private GetNumber m_Decay = new GetNumber(16);
        [SerializeField] private GetNumber m_DeltaTime = new GetNumber(
            new TypeNumberTimeDeltaTime()
        );

        public override Quaternion Get(Args args)
        {
            return MathUtils.ExponentialDecay(
                this.m_Current.Get(args), 
                this.m_Target.Get(args), 
                (float) this.m_Decay.Get(args), 
                (float) this.m_DeltaTime.Get(args)
            );
        }

        public override string ToString()
        {
            return $"Smooth to {this.m_Target}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
```

