planck.js icon indicating copy to clipboard operation
planck.js copied to clipboard

converting iforce tutorial examples to planck, couple of bugs found

Open bobcgausa opened this issue 4 years ago • 1 comments

angle on rotating objects seems to increment without limit, which is ok however, getAngle returns these ever-increasing numbers, suggest modding to -360 to 360 to facilitate position testing

iforce box2d world tutorial explains using setGravity however I tried running it up and down on a key press and it locked my app https://editor.p5js.org/Bobcook47/sketches/S2RqS8ie- when is it safe, if ever, to call setGravity

ps: if anyone knows how to get a mousejoint to work outside the testbed, please let me know

bobcgausa avatar Apr 23 '21 00:04 bobcgausa

suggest modding to -360 to 360 to facilitate position testing

Planck closely follows Box2D API, if this is how Box2D works we can change it.

however I tried running it up and down on a key press and it locked my app

It needs to be setGravity(Vec2(0, gravity)).

shakiba avatar Apr 24 '21 04:04 shakiba

MouseJoint needs three parameters:

bodyA - a ground body (I guess this is not used) bodyB - a body that is dragged by mouse target - a point in world frame that bodyB is dragged towards

To make bodyB follow the mouse, you need to call joint.setTarget(target) as the mouse moves.

shakiba avatar Aug 25 '23 07:08 shakiba