UnityEngine.Mathf.SmoothDamp C# (CSharp) Method

SmoothDamp() public static method

public static SmoothDamp ( float current, float target, float &currentVelocity, float smoothTime ) : float
current float
target float
currentVelocity float
smoothTime float
return float
        public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime)
        {
            var deltaTime = Time.deltaTime;
            const float maxSpeed = float.PositiveInfinity;
            return SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime);
        }

Same methods

Mathf::SmoothDamp ( float current, float target, float &currentVelocity, float smoothTime, float maxSpeed ) : float
Mathf::SmoothDamp ( float current, float target, float &currentVelocity, float smoothTime, float maxSpeed, float deltaTime ) : float

Usage Example

コード例 #1
0
        public void Update()
        {
            if (velocity.magnitude <= 0.01f)
            {
                velocity = Vector3.zero;
            }

            transform.position = GetCameraClampedPosition();

            var cameraPosition = GetCameraPosition();

            transform.position =
                RequiredSmoothDamp ?
                new Vector3(
                    Mathf.SmoothDamp(transform.position.x, cameraPosition.x, ref velocity.x, DampTimeX, DampMaxSpeedX),
                    Mathf.SmoothDamp(transform.position.y, cameraPosition.y, ref velocity.y, DampTimeY, DampMaxSpeedY),
                    cameraPosition.z
                    ) :
                cameraPosition;

            RequiredSmoothDamp = true;
        }
All Usage Examples Of UnityEngine.Mathf::SmoothDamp