# Vector3.SmoothDamp 平滑阻尼

static function SmoothDamp (current : Vector3, target : Vector3, ref currentVelocity : Vector3, smoothTime : float, maxSpeed : float = Mathf.Infinity, deltaTime : float = Time.deltaTime) : Vector3

### Parameters参数

• current
The current position.
当前的位置
• target
The position we are trying to reach.
我们试图接近的位置
• currentVelocity
The current velocity, this value is modified by the function every time you call it.
当前速度，这个值由你每次调用这个函数时被修改
• smoothTime
Approximately the time it will take to reach the target. A smaller value will reach the target faster.
到达目标的大约时间，较小的值将快速到达目标
• maxSpeed
Optionally allows you to clamp the maximum speed.
选择允许你限制的最大速度
• deltaTime
The time since the last call to this function. By default Time.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 example : 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);
}
}``````
``````// Smooth towards the target
//平滑朝向目标
var target : Transform;
var smoothTime = 0.3;
private var velocity = Vector3.zero;

function Update () {
// Define a target position above and behind the target transform
//定义一个目标位置在目标变换的上方并且在后面
var targetPosition : Vector3 = target.TransformPoint(Vector3(0, 5, -10));

// Smoothly move the camera towards that target position
//平滑地移动摄像机朝向目标位置
transform.position = Vector3.SmoothDamp(transform.position, targetPosition,
velocity, smoothTime);
}``````
Page last updated: 2011-1-16