Trajectories

This is a good time to start exploring physics. The better the physics model you develop the more realistic your game will be. User expect things to proceed the way they do in real life. They hate when they have to learn that things fall following different laws than the gravity they know. On the other hand you should let them deal with the gameplay and not the physics laws behind the game.

One of the first things we notice in nature is trajectories. The term seems scientific and it might e intimidating but it is found in almost all the games we play with our friends since we can remember. The term means the path an object follows when thrown. The ball from the hands of a baseball player, or when kicked by a soccer player. This means that everybody is familiar with the phenomenon and this is the reason I decided to start this series of physics articles with it.

The physics of movement

First of all we must start analyzing the phenomenon. What happens when we throw a ball for example. What forces act upon it and what effects they have on its state.

As Newton explained when there are no external forces acting upon an object then the object remains in the same state, either moving at constant speed or standing still. On the other hand if we apply a constant force the velocity of the object changes proportionally to the amount of matter within it, aka its mass. The rate of change is constant and is called acceleration. We use the term velocity which is a vector instead of speed which is a scalar. Actually speed is the length of the velocity vector. Vectors have the extra directional property. In the case of velocity its direction is the direction of the movement. What we said so far is actually the second law of motion described by Newton and its formal description is given by the equation:

F = mγ

Where F is the force, m the mass and γ the acceleration.

The velocity of the objects at any given time is calculated by the equation

v = v0 + γt

where v0 is the initial velocity γ the acceleration and t is the elapsed time.

The final location after that time is given by

s = s0 + v0t + γt2/2

Where s0 is the initial location, v0 the initial velocity, γ is the acceleration and t is the elapsed time.

The above equations are all we need to calculate the path of the object. Since velocity, acceleration and distance are vector quantities we do not need anything else in order to determine the accurate position and velocity of the object at any given time. All the above are based on the fact that you are familiar with the underlying vector math required.

Mathematical basics