Version: 2021.3
言語: 日本語
public static Vector3 SmoothDamp (Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed= Mathf.Infinity, float deltaTime= Time.deltaTime);

パラメーター

current 現在位置
target 目的地
currentVelocity 現在の速度。この値は関数が呼び出されるたびに変更されます。
smoothTime target へ到達するまでのおおよその時間。値が小さいほど、target に速く到達します。
maxSpeed オプションとして、最大速度を制限することができます。
deltaTime この関数が最後に呼び出されてからの経過時間。デフォルトは Time.deltaTime 変数。

説明

目的地に向かって時間の経過とともに徐々にベクトルを変化させます

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

// Smooth towards the target

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; public float smoothTime = 0.3F; private Vector3 velocity = Vector3.zero;

void Update() { // Define a target position above and behind the target transform Vector3 targetPosition = target.TransformPoint(new Vector3(0, 5, -10));

// Smoothly move the camera towards that target position transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime); } }