Is it possible to change a center of mass in MatterJS? #6442
-
|
Let's see we have some simple example of using matterjs like this one: Trying to change the center of ball's mass: but nothing changes because as it noted here it's read only property: https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Matter.Components.Mass.html Somewhere over Internet I found some trick: const offset = { x: 30, y: 0 };
this.ball.body.position.x += offset.x;
this.ball.body.position.y += offset.y;
this.ball.body.positionPrev.x += offset.x;
this.ball.body.positionPrev.y += offset.y;But as you might see I works weirdly. So is there a way to change the center of mass? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
|
Beta Was this translation helpful? Give feedback.

this.matter.body.setCentre(body, centre, relative)(see Matter docs for details).