This code should create a sprite when moving too
create() {
this.lizard = this.matter.add.sprite(400, 2000, "lizard", undefined).setFixedRotation();
}
update() {
const speed = 5;
if (this.cursors.left.isDown) {
this.lizard.setVelocityX(-speed);
} else if (this.cursors.right.isDown) {
this.lizard.setVelocityX(speed);
} else {
this.lizard.setVelocityX(0);
}
}
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.WEBGL,
width: window.innerWidth,
height: window.innerHeight,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
},
physics: {
default: "matter",
matter: {
debug: true,
// gravity: {
// y: 1,
// },
},
},
scene: [Preloader, Game],
plugins: {
scene: [
{
key: "rexUI",
plugin: UIPlugin,
mapping: "rexUI",
},
],
},
};
But when you move the sprite it flips
Everywhere they write that setFixedRotation fixed the situation, they also write to set body.inertia = Infinity but this also does not help. What to do?
Phaser 3.70