Moving Objects in Unity: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
TomasM (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
TomasM (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 11: | Zeile 11: | ||
'''Vector:''' A mathematical entity commonly drewn as an arrow in two or three dimensional space, which has a a magnitude (size or length) and a direction (angle θ). A class | '''Vector:''' A mathematical entity commonly drewn as an arrow in two or three dimensional space, which has a a magnitude (size or length) and a direction (angle θ). A class | ||
'''Vector3:''' is a Unity C# struct with given x, y & z components, representing points and vectors in 3D space. | '''Vector3:''' is a Unity C# struct with given x, y & z components, representing points and vectors in 3D space. In other words, a group of Vectors. | ||
private void Update() | |||
{ | |||
transform.position += transform.forward * Time.deltaTime; | |||
} |
Version vom 23. Oktober 2019, 14:12 Uhr
Unity : How to move an object in 3D space?
There are different ways to move an object within 3D space with code. Here we go over 5 options.
A) transform.position
Transform: a Class which contains the information of position, rotation and scale of an object.
transform.position: The position property of a GameObject's Transform. Assigns the object a new position.
Vector: A mathematical entity commonly drewn as an arrow in two or three dimensional space, which has a a magnitude (size or length) and a direction (angle θ). A class
Vector3: is a Unity C# struct with given x, y & z components, representing points and vectors in 3D space. In other words, a group of Vectors.
private void Update() { transform.position += transform.forward * Time.deltaTime; }