If you are shot at, move and move fast. If you can, move across the line of fire and not directly away from the shooting. If you are part of a group, scatter in different directions. This may confuse the person with the firearm, long enough to find cover.
Do not take cover behind vehicles. Pistol bullets easily pass through both doors of a car; rifle bullets can pass through a vehicle lengthwise; grenades, mortars and cannon shells can destroy most vehicles altogether. Stopped or disabled vehicles are "bullet magnets" that draw fire. The best protection provided by a car or truck is its ability to move away at high speed. If forced to take cover behind a vehicle or inside one, put the engine block between yourself and the shooter - it rarely gets penetrated by small arms fire.
Walls, trees, and structures provide concealment, but may not provide cover. The 7.62mm round used by the AK-47, a common assault rifle in war zones, can pass through a concrete block. The less powerful 9mm pistol round can go through a dozen layers of sheetrock.
A rule of thumb to keep in mind is the 'three-second rule' which basically states if you need to move to another place of cover, it should not be more than a three second sprint away. A good phrase to remember (if possible) is: 'I'm up, He's seen me, I'm down.' Basically, you are up out of cover and moving (fast), you assume the shooter has seen you and is taking aim, and then you are back down behind suitable defensive cover before he can fire.