function Translate (translation : Vector3, relativeTo : Space = Space.Self) : void
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 移動被應用相對於世界坐標系統。
function Update() { // Move the object forward along its z axis 1 unit/second. //沿着z軸1單位/秒,向前移動物體 transform.Translate(Vector3.forward * Time.deltaTime); // Move the object upward in world space 1 unit/second. //在世界坐標沿着y軸1單位/秒,向上移動物體 transform.Translate(Vector3.up * Time.deltaTime, Space.World); }
• function Translate (x : float, y : float, z : float, relativeTo : Space = Space.Self) : void
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 to the world coordinate system.
如果relativeTo留空或者設置為Space.Self,移動被應用相對於變換的自身軸。(當在場景視圖選擇物體時,x、y和z軸顯示)如果相對於Space.World 移動被應用相對於世界坐標系統。
function Update() { // Move the object forward along its z axis 1 unit/second. //沿着z軸每秒1單位向前移動物體 transform.Translate(0, 0, Time.deltaTime); // Move the object upward in world space 1 unit/second. //在世界坐標每秒1單位向上移動物體 transform.Translate(0, Time.deltaTime, 0, Space.World); }
• function Translate (translation : Vector3, relativeTo : Transform) : void
Description描述
Moves the transform in the direction and distance of translation.
移動transform在translation的方向和距離。
簡單的說,向某方向移動物體多少距離。
The movement is applied relative to /relativeTo/'s local coordinate system. If relativeTo is null, the movement is applied relative to the world coordinate system.
移動被應用相對於(relativeTo : Transform)的自身坐標系統。日光相對於為null,則移動被應用相對於世界坐標系統。
function Update() { // Move the object to the right relative to the camera 1 unit/second. //相對於攝像機每秒1單位向右移動物體 transform.Translate(Vector3.right * Time.deltaTime, Camera.main.transform); }
• function Translate (x : float, y : float, z : float, relativeTo : Transform) : void
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軸。
The movement is applied relative to /relativeTo/'s local coordinate system. If relativeTo is null, the movement is applied relative to the world coordinate system.
移動被應用相對於(relativeTo : Transform)的自身坐標系統。日光相對於為null,則移動被應用相對於世界坐標系統。
function Update() { // Move the object to the right relative to the camera 1 unit/second. //相對於攝像機每秒1單位向右移動物體 transform.Translate(Time.deltaTime, 0, 0, Camera.main.transform); }