Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Vector2.SmoothDamp

マニュアルに切り替える
public static Vector2 SmoothDamp(Vector2 current, Vector2 target, ref Vector2 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime);
public static Vector2 SmoothDamp(Vector2 current, Vector2 target, ref Vector2 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime);
public static Vector2 SmoothDamp(Vector2 current, Vector2 target, ref Vector2 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime);

パラメーター

current 現在の位置
target 目的地として向かう位置
currentVelocity 現在の速度。この値は関数が呼び出されるごとに変更されていきます
smoothTime 目的地に到達するのにかかる時間。値が小さいほど早く目的地に到達します
maxSpeed 最高速度
deltaTime この関数を呼び出してからの経過時間。デフォルトでは Update 関数内で実行されるのを考慮して Time.deltaTime

説明

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

ベクトルはスプリングとダンパーのような機能によってスムーズ化されるので目的地を行き過ぎてしまうことはありません。