Search the Blog

Monday, September 8, 2014

What's our Vector, Victor?

Ah vectors. The foundation of interpreting object's movement. Believe it or not, you use vectors every day of your life: They keep you bound to your seat, keep you from drifting away without friction. But how exactly do Vectors work? And how in gaming?

Vectors worked based on the concepts of direction and magnitude. A vector's direction denotes in which way the vector is apply its force, and its magnitude or length determines how much force is being exerted. For example, the Earth's gravity impedes a downward vector with a force pulling us towards the Earth's core. This force is strong enough to keep us bound to the planet's surface. Yet, by jumping into the air we can exert our own vertical vector that allows a person to lift off the ground. The sum of these vectors, however, causes us to be pulled back toward the Earth and not float away.


Lets put this into a gaming perspective. Every vector gives off a force that exerts something. Maybe it is traversing through water, maybe gravity. Whenever a character acts, they exert their own force. When opposing forces balance, then an entity is considered at rest. In the sample picture below, both the entity and world are at balance (S). Note that while there is gravity in the game world, the floor is exerting an upward force that keeps the entity from falling through the ground (i.e. replicating a solid object). When the entity preforms a jump, its vector exerts force that causes the character to jump in the air: This force must exceed that of the gravity in order for the entity to get off the ground (A). However, the once the entity reaches a certain distance (namely, the distance of the jump), it needs to be pulled back to the ground. At the peak of the jump, the vector zeros out to allow the ground to pull it back down. The same thing happens when jumping across (B); the difference here being that you have multiple vectors at work. Not only do you have the vector accelerating the jump, you also have the vector creating a forward momentum.


No comments:

Post a Comment