Birch-san / box2d-wasm

Box2D physics engine compiled to WebAssembly. Supports TypeScript and ES modules.
263 stars 21 forks source link

How to move the rigid body position after the rigid body is created #49

Closed a6965921 closed 2 years ago

a6965921 commented 2 years ago

How to move the rigid body position after the rigid body is created

i can't find SetPositon

Birch-san commented 2 years ago

best way is to create a mouseJoint:
https://github.com/Birch-san/liquidfun-play-2/blob/master/src/demo/gravity.ts#L182

that's how I attach the planet to the mouse:
https://birchlabs.co.uk/liquidfun-wasm/

or you could use SetTransform():
https://stackoverflow.com/a/8582770/5257399