Character movement with vectors- Unit Length vectors
Normalized Vectors or Unit length vectors are very useful and used everywhere in game development.
Consider the example of Pacman(P) and the ghost, Inky (I). Lets say we want the Pacman to move away from Inky but also keep an eye on Inky. So Pacman wants to face Inky even as he is going down away from Inky. id the velocity of Pacman in downward direction. We are interested in the vector that pacman is looking along i.e.
We learnt in the previous tutorial
Ideally when we store vectors that represent where characters are looking, we use a unit length vector which means the character can face whereever it wants to but its magnitude is one. We are going to denote this unit length vector by
PI^ = /
In terms of x and y coordinates:
PI^ = ( / , / )
PI^ is always a vector whose magnitude is one.