Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

Transform.Translate

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public function Translate(translation: Vector3, relativeTo: Space = Space.Self): void;
public void Translate(Vector3 translation, Space relativeTo = Space.Self);
public function Translate(translation: Vector3, relativeTo: Space = Space.Self): void;
public void Translate(Vector3 translation, Space relativeTo = Space.Self);

Parámetros

Descripción

Moves the transform in the direction and distance of 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.

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

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

Parámetros

Descripción

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

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.

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

public function Translate(translation: Vector3, relativeTo: Transform): void;
public void Translate(Vector3 translation, Transform relativeTo);

Parámetros

Descripción

Moves the transform in the direction and distance of 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.

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

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

Parámetros

Descripción

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

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.

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