+91 9591117915 info@pixtell.net

Character movement with vectors- Unit Length vectors

Pixtell Labs gamedev, Tutorials Character movement with vectors- Unit Length vectors
Character movement with vectors- Unit Length vectors

gamedev Tutorials

Character movement with vectors- Unit Length vectors

Posted By Kirti P

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. \vec v id the velocity of Pacman in downward direction. We are interested in the vector that pacman is looking along i.e. \vec PI

tutorial6

We learnt in the previous tutorial

\vec PI\vec I – \vec P

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^ = \vec PI\mid\vec PI\mid

 

In terms of x and y coordinates:

PI^ = ( \vec PIx\mid\vec PI\mid ,  \vec PIy\mid\vec PI\mid )

PI^ is always a vector whose magnitude is one.

 

Tagged

Leave a Reply

Your email address will not be published. Required fields are marked *