If you’re talking old movies with revolver pistols, cocking the gun sets the hammer ready to fire. Cap guns that mimic them mechanically do this automatically, for example.
If you’re talking modern movies, cocking the gun chambers a round and releases a spent one if needed. The gun CAN do this automatically but doing this saves fractions of time in actual situations and is a more visually appealing way to show that the gun is loaded and primed to fire in a movie setting.
Latest Answers