New Physics methods - attach() and unattach()

We can now attach a physics object to a ZIM object that has no physics. This is a joint like the mousejoint but joins to the x and y of a ZIM object. The ZIM object can be moved with drag() or animate() or wiggle() etc. and the physics object will follow it! The original distance is generally kept although it is a force based so the mass of the physics object will affect the distance. See https://zimjs.com/valentines/puppets.html and https://zimjs.com/valentines/puppets2.html

const physics = new Physics(0);
// make a ZIM object to drag(), animate() or wiggle()
const control = new Triangle().center().mov(0,-100).drag(); 
const ball = new Circle().center().addPhysics();
physics.attach(control, ball); // physics ball will be moved by triangle

3 Likes

Wow! so smart!

1 Like

Yes!! Should have thought of that before... this will be quite handy. We will be able to animate along squiggle and blob paths and have that animation be used in the Physics world.