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.
Answered by
photonstorm
Mar 31, 2023
Replies: 1 comment 3 replies
-
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ProgrammingLife
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this.matter.body.setCentre(body, centre, relative)
(see Matter docs for details).