Set Maximum Delta Time#
Time / Set Maximum Delta Time
Description#
Sets the upper limit a single frame can take, capping physics steps after a hitch
Parameters#
| Name | Description |
|---|---|
| Maximum Delta Time | The largest delta time in seconds a frame is allowed to report |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Set Maximum Delta Time")]
[Image(typeof(IconClock), ColorTheme.Type.Blue, typeof(BadgeDelta))]
[Description("Sets the upper limit a single frame can take, capping physics steps after a hitch")]
[Category("Time/Set Maximum Delta Time")]
[Parameter("Maximum Delta Time", "The largest delta time in seconds a frame is allowed to report")]
[Keywords("Cap", "Clamp", "Limit", "Frame", "Spike", "Hitch", "Delta")]
[Serializable]
public class InstructionCoreTimeSetMaximumDeltaTime : Instruction
{
[SerializeField] private GetNumber m_MaximumDeltaTime = new GetNumber(0.3333333);
protected override string GetTitle(GameObject source)
{
string maxTime = TextUtils.ThemeAsKeyword("Maximum Delta Time");
return $"Set {maxTime} = {this.m_MaximumDeltaTime}";
}
protected override Awaitable Run(Args args)
{
Time.maximumDeltaTime = Mathf.Max(0f, (float) this.m_MaximumDeltaTime.Get(args));
return Done;
}
}
}