You don't need a physics engine to re-create magnets in the way you need, besides - most engines assume that a magnet is a point in space.
For example, B3d code, which doesn't work off the bat but you get the idea.
For example, B3d code, which doesn't work off the bat but you get the idea.
Const BSx# = 0 Const BSy# = 0 Const BSradius# = 500 Const BSmagneticforce# = 10 Const Pmagneticforce# = 1 Const TIMESTEP# = .05 Type Particle Field x#, y# Field vx#, vy# Field fx#, fy# End Type . . . For p.particle = Each particle ;BIG OUTER SPHERE ;normalise direction to big sphere ( BS ) outer radius Nx# = p\x - BSx Ny# = p\y - BSy D# = Sqr( Nx * Nx + Ny * Ny ) Nx = Nx / D Ny = Ny / D ;get distance to outer radius DistanceToBS# = BSradius - D ;calculate inverse magnetic force Force# = BSmagneticforce / ( DistanceBS * DistanceBS ) ;accumulate force p\fx = p\fx + Nx * Force p\fy = p\fy + Ny * Force ;PARTICLES For q.particle = Each particle If q <> p ;normalise direction to other particle Nx = q\x - p\x Ny = q\y - p\y D# = Sqr( Nx * Nx + Ny * Ny ) Nx = Nx / D Ny = Ny / D Force# = Pmagneticforce / ( DistanceBS * DistanceBS ) p\fx = p\fx + Nx * Force p\fy = p\fy + Ny * Force q\fx = q\fx - Nx * Force q\fy = q\fy - Ny * Force EndIf Next ;add force to velocity p\vx = p\vx + p\Fx * TIMESTEP p\vy = p\vy + p\Fy * TIMESTEP ;add velocity to position p\x = p\x + p\vx p\y = p\y + p\vy ;reset forces p\fx = 0 p\fy = 0 Next