It doesn’t make much of a difference here, because the numbers are so small.
However, yes, I think direction should be normalised. I am scaling a vector so that I am travelling the same distance no matter which direction I am going.
Let’s say forwardVector
is [0, 0, 1]
which would make rightVector
[1, 0, 0]
, and translationAmount
is 1
.
If I take one step forward, then direction is [0, 0, 1]
.
No normalizing: transform.position
= [0, 0, 1]
.
Normalizing: transform.position
= [0, 0, 1]
.
The distance I have travelled is 1
for both vectors. (length of vector)
If I take one step diagonally forward and one to the right, then direction is [1, 0, 1]
. Note that in this example, I’m not really taking two steps (one forward and one right). By pressing two keys, I am taking one step diagonally, and I should move the same distance as moving one forward.
No normalizing: transform.position
= [1, 0, 1]
. Distance is 1.414.
Normalizing: transform.position
= [0.707, 0, 0.707]
. Distance is 1
Notice that the distance travelled without normalizing is higher than if I just moved one forward.
(However, I have just noticed that transform.position +=
should be transform.position =
. )