pymunk
pymunk copied to clipboard
Electricity and general attractive/repulsive force?
pymunk.Body seems to only support gravitation, but not other types of mechanical forces, e.g. electricity. Is it possible to specify body electric charges?
More generally: is it possible to specify polynomial attractive/repulsive force, and specify its per-body "charges"?
There is no built in ready to use support for this. You will have to do something yourself.
There are some resources for Chipmunk (The c library pymunk is using) that you might find useful: https://chipmunk-physics.net/forum/viewtopic.php?f=1&t=1433&p=6906 https://github.com/slembcke/Chipmunk2D/blob/b56ae7591b78acc6bb72401ee999d0e9b5019305/Demo/MagnetsElectric.c https://github.com/slembcke/Chipmunk2D/blob/master/demo/Planet.c
Rereading this issue I see that another thing should be clarified: Pymunk does not calculate any gravity force between two bodies. The only thing it does is calculate how the gravity set on the space should affect each body.