How do I move body position for Matter JS?
// 'this' is referring to the sprite object
this.scene.matter.add.gameObject(this, { isStatic: true });
Then, in the update loop of the same object I am doing
this.body.x = newX;
this.body.y = newY;
this.body.angle = newRotation;
But I don’t see anything moves, the debug body display stays still and not moving at all even though in my console log, I can see the x, y and angle value changes.
What am I doing wrong?
The only reason I am trying to manually move it is because this object is within a container. When I move or rotate the container, the body of the matterjs child doesn’t move at all. So I am trying to move it manually by getting the global value of that child.
This method works if I am using arcade physics, the only issue with arcade physics, you cannot rotate the body. While matterjs works for rotation, it doesn’t see to work for child of container. And manual move doesn’t work at all like physics arcade does.