Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Exponential Decay#

Math / Algebra / Exponential Decay

  • Can Read

  • Cannot Write

Description#

Interpolates a value from Current to Target over time

Note

Useful Decay values range between 1 and 25

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Exponential Decay")]
    [Category("Math/Algebra/Exponential Decay")]
    
    [Description("Interpolates a 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 TypeNumberMathExponentialDecay : TypeNumber
    {
        [SerializeField] private GetNumber m_Current = new GetNumber();
        [SerializeField] private GetNumber m_Target = new GetNumber();
        
        [SerializeField] private GetNumber m_Decay = new GetNumber(16);
        [SerializeField] private GetNumber m_DeltaTime = new GetNumber(
            new TypeNumberTimeDeltaTime()
        );
        
        public override double Get(Args args)
        {
            double current = this.m_Current.Get(args);
            double target = this.m_Target.Get(args);
            double decay = this.m_Decay.Get(args);
            double deltaTime = this.m_DeltaTime.Get(args);
            
            return MathUtils.ExponentialDecay(current, target, decay, deltaTime);
        }

        public override string ToString()
        {
            return $"Smooth to {this.m_Target}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.