用户工具

站点工具


侧边栏

script:unityengine:classes:transform:transform.translate

Transform.Translate 平移

JavaScript ⇒ Translate(translation: Vector3, relativeTo: Space = Space.Self): void;
C# ⇒ void Translate(Vector3 translation, Space relativeTo = Space.Self);

Description 描述

Moves the transform in the direction and distance of translation.

移动transform在translation的方向和距离。

简单的说,向某方向移动物体多少距离。

If relativeTo is left out or set to Space.Self the movement is applied relative to the transform's local axes. (the x, y and z axes shown when selecting the object inside the Scene View.) If relativeTo is Space.World the movement is applied relative to the world coordinate system.

如果relativeTo留空或者设置为Space.Self,移动被应用相对于变换的自身轴。(当在场景视图选择物体时,x、y和z轴显示)如果相对于Space.World 移动被应用相对于世界坐标系统。

JavaScript:

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

C#:

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

JavaScript ⇒ Translate(x: float, y: float, z: float, relativeTo: Space = Space.Self): void;
C# ⇒ void Translate(float x, float y, float z, Space relativeTo = Space.Self);

Description 描述

Moves the transform by x along the x axis, y along the y axis, and z along the z axis.

移动变换由x沿着x轴,y沿着y轴,z沿着z轴。

If relativeTo is left out or set to Space.Self the movement is applied relative to the transform's local axes. (the x, y and z axes shown when selecting the object inside the Scene View.) If relativeTo is Space.World the movement is applied relative t

script/unityengine/classes/transform/transform.translate.txt · 最后更改: 2016/08/02 05:37 (外部编辑)