Present day cars use helical gears and synchromesh devices within the gearboxes, that synchronize the rotation of gears which might be about to mesh. This removes clashing with the gears and helps make equipment shifting less difficult. The dog clutch slides on the main shaft to rotate with it. https://sethhkmmk.pages10.com/the-basic-principles-of-gearbox-69158165