translation の方向と距離に移動します
relativeTo を設定しないか、 Space.Self を設定した場合、移動は Transform のローカル軸で適用されます。(シーンビュー内でオブジェクトを選択しているときに見えている X、Y、Z 軸)
relativeTo が Space.World の場合、移動はワールド座標を基準に適用されます。
function Update() {
// Move the object forward along its z axis 1 unit/second.
transform.Translate(Vector3.forward * Time.deltaTime);
// Move the object upward in world space 1 unit/second.
transform.Translate(Vector3.up * Time.deltaTime, Space.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); } }
x軸に沿って z、 y 軸に沿って z、z 軸に沿って z で移動させます。
relativeTo を設定しないか、 Space.Self を設定した場合、移動は Transform のローカル軸で適用されます。(シーンビュー内でオブジェクトを選択しているときに見えている X、Y、Z 軸)
relativeTo が Space.World の場合、移動はワールド座標を基準に適用されます。
function Update() {
// Move the object forward along its z axis 1 unit/second.
transform.Translate(0, 0, Time.deltaTime);
// Move the object upward in world space 1 unit/second.
transform.Translate(0, Time.deltaTime, 0, Space.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); } }
translation の方向と距離に移動します
移動は relativeTo のローカル座標を基準に適用されます。
relativeTo が null の場合、移動はワールド座標を基準に適用されます。
function Update() {
// Move the object to the right relative to the camera 1 unit/second.
transform.Translate(Vector3.right * Time.deltaTime, Camera.main.transform);
}
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void Update() { transform.Translate(Vector3.right * Time.deltaTime, Camera.main.transform); } }
x軸に沿って z、 y 軸に沿って z、z 軸に沿って z で移動させます。
移動は relativeTo のローカル座標を基準に適用されます。
relativeTo が null の場合、移動はワールド座標を基準に適用されます。
function Update() {
// Move the object to the right relative to the camera 1 unit/second.
transform.Translate(Time.deltaTime, 0, 0, Camera.main.transform);
}
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void Update() { transform.Translate(Time.deltaTime, 0, 0, Camera.main.transform); } }