How to replace an object in a group?

Hi there,

Is it possible to replace an object in a group without changing the order of the objects already in the group?

Many thanks.

Hey :slight_smile:

I haven’t tested this but maybe this will work?
https://photonstorm.github.io/phaser3-docs/Phaser.Utils.Array.html#.Replace__anchor

Phaser.Utils.Array.Replace(group.children, oldObject, newObject);

Maybe try

const index = group.getChildren().indexOf(a);

group.remove(a);
group.add(b);
Phaser.Utils.Array.MoveTo(group.getChildren(), b, index);