What is the difference between translate and position
Here is a dumb question, what is the difference between translate and position.
Here's an example.
void Update () {
if (Input.GetKey (KeyCode.T)) {
transform.Translate (Vector3.up * Time.deltaTime);
}
if (Input.GetKey (KeyCode.Space)) {
transform.position += Vector3.up * Time.deltaTime;
}
}
I made this code and T/Space do the samething so what is the difference ?
Comment
Best Answer
Answer by Statement · Oct 28, 2015 at 07:46 PM
Translate will do a local translation while setting position doesn't account for rotation.
Rotate your object and try both methods and you'll see the difference.
T will move in the direction the transform "is standing". Space will move in the world up direction.