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

スクリプト言語

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

Vector3.SmoothDamp

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public static function SmoothDamp(current: Vector3, target: Vector3, ref currentVelocity: Vector3, smoothTime: float, maxSpeed: float = Mathf.Infinity, deltaTime: float = Time.deltaTime): Vector3;
public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime);
public static function SmoothDamp(current: Vector3, target: Vector3, ref currentVelocity: Vector3, smoothTime: float, maxSpeed: float = Mathf.Infinity, deltaTime: float = Time.deltaTime): Vector3;
public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime);
public static function SmoothDamp(current: Vector3, target: Vector3, ref currentVelocity: Vector3, smoothTime: float, maxSpeed: float = Mathf.Infinity, deltaTime: float = Time.deltaTime): Vector3;
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 目的地に到達するのにかかる時間。値が小さいほど早く目的地に到達します
maxSpeed 最高速度
deltaTime この関数を呼び出してからの経過時間。デフォルトでは Update 関数内で実行されるのを考慮して Time.deltaTime

説明

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

ベクトルはスプリングとダンパーのような機能によってスムーズ化されるので目的地を行き過ぎてしまうことはありません。 もっとも一般的な使い方はカメラの追従をスムーズにするために使います。

	// 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); }
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); } }