Version: 2017.2
public static Vector3 SmoothDamp (Vector3 current, Vector3 target, ref Vector3 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

Gradually changes a vector towards a desired goal over time.

The vector is smoothed by some spring-damper like function, which will never overshoot. The most common use is for smoothing a follow camera.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; public float smoothTime = 0.3F; private Vector3 velocity = Vector3.zero; void Update() { Vector3 targetPosition = target.TransformPoint(new Vector3(0, 5, -10)); transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961