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

スクリプト言語

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

Transform.Translate

マニュアルに切り替える
public void Translate(Vector3 translation, Space relativeTo = Space.Self);
public void Translate(Vector3 translation, Space relativeTo = Space.Self);

パラメーター

説明

translation の方向と距離に移動します

relativeTo を設定しないか、 Space.Self を設定した場合、移動は Transform のローカル軸で適用されます。(シーンビュー内でオブジェクトを選択しているときに見えている X、Y、Z 軸) relativeToSpace.World の場合、移動はワールド座標を基準に適用されます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { transform.Translate(Vector3.forward * Time.deltaTime); transform.Translate(Vector3.up * Time.deltaTime, Space.World); } }

public void Translate(float x, float y, float z, Space relativeTo = Space.Self);
public void Translate(float x, float y, float z, Space relativeTo = Space.Self);

パラメーター

説明

x軸に沿って z、 y 軸に沿って z、z 軸に沿って z で移動させます。

relativeTo を設定しないか、 Space.Self を設定した場合、移動は Transform のローカル軸で適用されます。(シーンビュー内でオブジェクトを選択しているときに見えている X、Y、Z 軸) relativeToSpace.World の場合、移動はワールド座標を基準に適用されます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { transform.Translate(0, 0, Time.deltaTime); transform.Translate(0, Time.deltaTime, 0, Space.World); } }

public void Translate(Vector3 translation, Transform relativeTo);

パラメーター

説明

translation の方向と距離に移動します

移動は relativeTo のローカル座標を基準に適用されます。 relativeTo が null の場合、移動はワールド座標を基準に適用されます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { transform.Translate(Vector3.right * Time.deltaTime, Camera.main.transform); } }

public void Translate(float x, float y, float z, Transform relativeTo);

パラメーター

説明

x軸に沿って z、 y 軸に沿って z、z 軸に沿って z で移動させます。

移動は relativeTo のローカル座標を基準に適用されます。 relativeTo が null の場合、移動はワールド座標を基準に適用されます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { transform.Translate(Time.deltaTime, 0, 0, Camera.main.transform); } }