12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using UnityEngine;
- namespace Animancer
- {
-
- partial class ControllerState
- {
-
-
-
-
-
-
- public class DampedFloatParameter
- {
-
-
- public ParameterID parameter;
-
- public float smoothTime;
-
- public float currentValue;
-
- public float targetValue;
-
- public float maxSpeed;
-
- public float velocity;
-
-
- public DampedFloatParameter(
- ParameterID parameter,
- float smoothTime,
- float defaultValue = 0,
- float maxSpeed = float.PositiveInfinity)
- {
- this.parameter = parameter;
- this.smoothTime = smoothTime;
- currentValue = targetValue = defaultValue;
- this.maxSpeed = maxSpeed;
- }
-
-
- public void Apply(ControllerState controller)
- => Apply(controller, UnityEngine.Time.deltaTime);
-
- public void Apply(ControllerState controller, float deltaTime)
- {
- currentValue = Mathf.SmoothDamp(currentValue, targetValue, ref velocity, smoothTime, maxSpeed, deltaTime);
- controller.SetFloat(parameter, currentValue);
- }
-
- }
-
- }
- }
|