Gravity and Drag
Assume that a projectile, with mass m starts its trajectory at a height h equal to the height of the aircraft, and with a forward speed v that is the sum of the speed generated by the propellant in the cartridge case and the speed of the aircraft. The important variables are the kinetic energy Ek = 1/2 m v2, the potential energy Ep = m g h, and the momentum p = m v.
Conservation of total energy and momentum are fundamental laws of physics. These quantities can not be destroyed, only exchanged with some other particles, or converted to a different form. As the projectile falls, its potential energy is converted into kinetic energy: It accelerates vertically, with an acceleration g. In a vacuum the projectile would retain its horizontal speed, and follow a parabolic curve (red).

In air the projectile encounters drag, a speed-dependent force. The air molecules absorb part of the energy and momentum of the projectile, while the friction converts some of the energy to heat. In general this results in a trajectory that is more curved (blue), although a properly designed round might also have some body lift, counteracting gravity. The line of sight is made to coincide as close as possible with the curve over the ranges expected in combat (green). Thus, often the guns are given a slight upwards angle, to make the match easier. For guns in the wings this is convenient, because the wings have a positive angle of attack.
In addition, in WWII fighters the line of sight itself might be chosen a few degrees above the flightpath, because the view forward and downward was restricted by the contours of the engine; so it was advantageous to move the aiming point upwards, into the field of view of the pilot. As in many conditions the pilot had to “lead” the target, i.e. aim in front of it, it was important to have a large enough viewing angle around the aiming point.
Gravity is of course the same for all projectiles. The drag is determined by their cross-section and aerodynamic shape, but independent of the weight. Drag is a force, and the same amount of drag will slow down a lighter projectile more: It has less momentum than a heavier one flying with the same speed. The mass is proportional to the volume, and therefore to the third power of the calibre; but the cross-section, and hence the drag, are proportional to the square of the calibre. Hence large calibre projectiles tend to retain their speed better, and have a longer range.
An alternative, however, is to fire a sub-calibre round, for example a discarding-sabot or squeeze-bore projectile. Because the gun is relatively powerful compared to the calibre, the initial speed will be high; and because the projectile has a slender profile, the drag will be low. By using an elongated projectile, it can still have a large mass. However, such guns tend to be designed for anti-armour use, not for anti-aircraft roles.
Evidently, rounds with a different mass or drag constant will follow different trajectories. Designers will try to choose propellants and weights to give different types of ammunition approximately the same trajectory, but this is hard to achieve. Tracer ammunition almost always has a different trajectory, because it is lighter and the burning of the tracer produces gas, reducing the drag of the projectile.
The problem is even more complicated when different types of gun are installed. During WWII that was common practice.
Harmonisation
If a gun is close to the centreline of a fighter, the trajectory will be parallel to the course of the aircraft, and there is no harmonisation problem (red). However, on a single-engined tractor aircraft such guns must be synchronised to fire through the propeller disc, and this increases weight, reduces the rate of fire, and imposes strict conditions on the quality of the ammunition. And not all guns can be synchronized; some gun mechanisms are unsuitable. An alternative is arranging a gun to fire through the hollow axis of the propeller, but of course this is restricted to a single weapon.

If the guns are in the wings outboard of the propeller disc, they can be made to converge on a spot in the distance, corresponding with the most common distance of fire. This will give maximal weight of fire on a small spot (left), but requires accurating aiming and judgment of the range. An alternative is to harmonize the guns to a series of different distances (right), to create a larger zone of fire, sacrificing destructive power for a larger probability to hit the target.
For most jet aircraft this problem is eliminated. There is no propeller, there is room in the nose for weapons because the engine has been moved aft, and their thin wings are not very suitable to fit armament in anyway. Because ingestion of gun gases by the engines must be carefully avoided, guns are often mounted some distance back from the nose.
Deflection Shooting

If the target moves across the course of the fighter, a certain amount of lead has to be taken into account: One has to fire at the point in space where the target will be when the projectiles arrive. To maintain a longer burst on the target, the fighter has to fly a curve while firing, i.e. it is turning at some rate. Evidently, there would be no problem if the projectiles arrived instantaneously. Of course they do not, but it is advantageous to reduce the time of flight as much as possible, by using guns with a high muzzle velocity. For example, the time of flight to 500 yards for the Browning .50 gun is 0.62 seconds. A flighter flying at 650km/h travels 112m in that time!
For most of WWII, the amount of lead required was left to the judgment of the pilot, with minimal assistance by his gunsight. Typically, deflector gunsights offered some means of estimating range, by comparing the known, dialled in, wing span of the enemy with markers (horizontal lines above) controlled by the pilot. The projected ring then gave an indication of the amount of deflection needed, but only an indication: The speed of the target across the firing line had to be estimated. Most pilots were not good at deflection shooting.
At the end of WWII gyroscopic gunsights were developed in Britain, and they soon appeared on both British and American aircraft. (A German equivalent was produced, but it was not sufficiently reliable.) The range still had to be determined in the same way. But if the pilot then turned the fighter at a certain rate to keep the target in sight, the gunsight would present a prediction of where the projectiles would be at that range. It did this by measuring the acceleration felt by the gyroscope, corresponding to the turn rate. The figher pilot then only had to make this spot coincide with the target. The result was a large increase in armament effectiveness.
After WWII, radar ranging gunsights appeared, often with computers built-in to provide an accurate prediction of the trajectory. Today’s gunsights, if properly used, ensure an almost certain hit.
Own Speed Factor
Defensive gunners on a bomber aircraft, operating flexible guns, also had to cope with curved trajectories and deflection. In addition, they had the problem of the own speed factor. If they fire at a target on the beam, the bullets have the forward speed of the aircraft. Drag will not only curve the trajectory in the vertical plane, it will have the effect of “blowing back” the projectile, resulting in a trajectory that is curved backwards.
Various computing and compensating gunsights were developed before and during WWII, but apparently they were relatively little used for simple flexible gun installations. Powered gun turrets had more sophisticated sighting systems.
Next: WWII Fighters