[SOLVED] How do you sync the rigid bodies of all child nodes

I have a entity which has a number of child entities which have rigid bodies. I am moving the parent entity but although that changes the position of the child entities it doesn’t move the rigid bodies. Is there a way of ensuring that the rigid bodies of the children keep in sync with the parents movements.

You can mark this as solved, i did the following and it worked.

 this.buttons = menuobject.getChildren();

    for(var i = 0; i < this.buttons.length ; i++){
        var thisChild = this.buttons[i];
1 Like

syncEntityToBody is not public API. You should use teleport to move dynamic rigid bodies (although you shouldn’t really do this every frame - it’s more a mechanism to, say, reset a level to start state for example). For kinematic bodies, you can just use the regular transformation functions that can be applied directly to an entity (translate, rotate, etc).

Hi Will,
Not sure how that would be possible in this case as I only know where the parent has moved to and not where the individual child elements are positioned. But it’s ok because I am not doing it every frame, it’s only when the menu is first opened.

It works like this: I have a parent entity which I attach buttons to. I use the editor to do the “layout of the UI”.

When it runs the menu button on the controller causes an event which then takes the current camera position and projects it forward about a metre ,enables and positions the parent entity there. It’s working very nicely :slight_smile: