Version: 2017.3

Mathf.SmoothDamp

Switch to Manual
public static float SmoothDamp (float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed= Mathf.Infinity, float deltaTime= Time.deltaTime);

Parameters

current @param current Текущая позиция.
target @param target Позиция которой хотим достичь.
currentVelocity @param currentVelocity Текущая скорость. Это значение модифицируется функцией каждый раз, когда вы вызываете ее.
smoothTime @param smoothTime Приблизительное время требующееся для достижения цели. Наименьшее значение достигнет цели быстрее.
maxSpeed @param maxSpeed Опционально позволяет вам ограничить максимальную скорость.
deltaTime @param deltaTime Время прошедшее с последнего вызова данной функции. По умолчанию Time.deltaTime.

Description

Постепенно меняет значение в направлении определенной цели с течением времени.

The value is smoothed by some spring-damper like function, which will never overshoot. The function can be used to smooth any kind of value, positions, colors, scalars.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; public float smoothTime = 0.3F; private float yVelocity = 0.0F; void Update() { float newPosition = Mathf.SmoothDamp(transform.position.y, target.position.y, ref yVelocity, smoothTime); transform.position = new Vector3(transform.position.x, newPosition, transform.position.z); } }