transform.Translate differences on Vector3 vs transform.position

Hi all,

Coding conundrum ~

I’m using the following code to move my player back a small amount

transform.Translate(Vector3.back * 0.2f);

If I use the following code the results aren’t the same:

transform.position = (Vector3.back * 0.2f);

What is the Translate function doing different to affect my Vector3?

Ideally I wanted to do something like the code below but I was prevented with issues as "Cannot implicitly convert type ‘void’ to Vector3 etc

destination = transform.Translate(Vector3.back * 0.2f);
  1. Read the docs on Transform.

  2. Assigning a Vector3 to transform.position moves that transform to an absolute position, in this case 0.2 meters “back” from world center.

  3. Translate moves the transform by a relative amount.

  4. Translate returns void, which is why you can’t assign the result to transform.position.

  5. If you really want to assign that relative movement to a variable, do it like this:

var dest : Vector3 = transform.position + Vector3.back * 0.2f;