I have this sprite group
this.photons = this.physics.add.group({
key: "photon",
repeat: 11,
setXY: { x: 50, y: 50, stepX: 32 },
});
this.photons.children.iterate(function (child) {
child.body.bounce.set(1);
child.setVelocity(Phaser.Math.Between(300, 500),20);
child.body.collideWorldBounds = true;
});
Edit:
the children are colliding with each other by this.physics.add.collider(this.photons, this.photons);
Edit: Camera Code
const cursors = this.input.keyboard.createCursorKeys();
const controlConfig = {
camera: this.cameras.main,
left: cursors.left,
right: cursors.right,
up: cursors.up,
down: cursors.down,
acceleration: 0.06,
drag: 0.0005,
maxSpeed: 1.0,
};
this.controls = new Phaser.Cameras.Controls.SmoothedKeyControl(
controlConfig
);
How can I make every child face the direction of their vector, changing every collision?