I have a top-down character object that is a Container of various parts. This character can have elements that should move along with it (think a health bar, a speech bubble) that should NOT rotate when the character rotates.
If I add it to the Container, it rotates by default. If I don't add it to the Container, the element needs to be moved separately to keep up.
Neither of those work super well for me. Is there a neat way to flag that part of a Container should not rotate with it? Or that one object should stick to another without having them be in a Container? 🤔
I have added a functional snippet below. My goal is to have the ability to rotate the character container WITHOUT rotating the text field while still having the text field follow my character when it moves.
class DemoScene extends Phaser.Scene { create () { this.character = new Phaser.GameObjects.Container(this, 100, 100); this.character.add(this.add.circle(0, 0, 35, 0x00ff00)); this.character.add(this.add.rectangle(0, 20, 40, 40, 0x009900) .setAngle(45)); this.character.add(this.add.text(40, -20, 'Hi there!')); this.add.existing(this.character); this.tweens.add({ targets: this.character, x: 400, angle: 180, repeat: -1, duration: 3000, yoyo: 1 }); } } var config = { width: 540, height: 180, scene: DemoScene, }; new Phaser.Game(config); console.clear(); document.body.style = 'margin:0;'; <script src="//cdn.jsdelivr.net/npm/phaser/dist/phaser.min.js"></script> 