Skip to content

Recenter a group built at run time

Updated

A script spawns four bricks under the Pile group, then calls recenter() on its Group component, so the pile spins around the middle of its bricks instead of its old origin.

Watch the bricks turn around their own centre; the log says how many entities recenter() moved. Drag to orbit the camera, scroll to zoom.

Recenter a group built at run time

The script is explained step by step in Recenter a group built at run time.

Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.

RecenterPile.xrproj