We investigate the roles of magnetic fields and ambipolar diffusion during prestellar core formation in turbulent giant molecular clouds ( GMCs ) , using three-dimensional numerical simulations . Our simulations focus on the shocked layer produced by a converging large-scale flow , and survey varying ionization and angle between the upstream flow and magnetic field . We also include ideal magnetohydrodynamic ( MHD ) and hydrodynamic models . From our simulations , we identify hundreds of self-gravitating cores that form within 1 Myr , with masses M \sim 0.04 - 2.5 M _ { \odot } and sizes L \sim 0.015 - 0.07 pc , consistent with observations of the peak of the core mass function ( CMF ) . Median values are M = 0.47 ~ { } \mathrm { M } _ { \odot } and L = 0.03 pc . Core masses and sizes do not depend on either the ionization or upstream magnetic field direction . In contrast , the mass-to-flux ratio does increase with lower ionization , from twice to four times the critical value . The higher mass-to-flux ratio for low ionization is the result of enhanced transient ambipolar diffusion when the shocked layer first forms . However , ambipolar diffusion is not necessary to form low-mass supercritical cores . For ideal MHD , we find similar masses to other cases . These masses are 1 - 2 orders of magnitude lower than the value M _ { \mathrm { mag,sph } } = 0.007 ~ { } B ^ { 3 } / ( G ^ { 3 / 2 } \rho ^ { 2 } ) that defines a magnetically supercritical sphere under post-shock ambient conditions . This discrepancy is the result of anisotropic contraction along field lines , which is clearly evident in both ideal MHD and diffusive simulations . We interpret our numerical findings using a simple scaling argument which suggests that gravitationally critical core masses will depend on the sound speed and mean turbulent pressure in a cloud , regardless of magnetic effects .