How to move all boxes created from button?

How would I go about being able to move all boxes with key event after they were created. After clicking the button 3 times, 3 different colored boxes are created and I would like to move all 3 of them with an key input “w”
https://www.babylonjs-playground.com/#K2QRCM

Hiya MG.

https://www.babylonjs-playground.com/#K2QRCM#1

Just keep clicking. After three boxes are made, continued clicks make all three boxes… randomly move and spin… because they all have an invisible “parent”… or “group manager”… or “gizmo”.

Notice line 52… we make a transformNode… just a blank nothing-ness that we can use as an invisible move-able “thing”.

In line 75, I set each of the 3 new boxes… parent = gizmo.

Line 73 if (boxCount < nbPlayers) { … then make another box. IF FALSE… goto lines 84-86 with each button press. In that area… I m moving and spinning gizmo, which also moves and spins (and scales)… all three boxes… because gizmo is the boss.

That should get you rolling. :slight_smile: You can now activate some keypresses… and move gizmo-around with those keypresses. Good luck, I hope I was helpful.

1 Like