Children's Rigidbody Invalid when Teleport Parent's Rigidbody

Hi, in this project :

You can see the ball running on the road where some obstacles are set on it. Those obstacles are all with rigidbody and are the children of roads.
In order to make an endless road, there are 12 piece of roads. When the ball collides with the addRoadTrigger, the last piece of road with be teleported to the head. However, the rigidbody on obstacle was gone when its parent’s rigidbody was teleported.

So, is it a bug ? You can try it out. PlayCanvas | HTML5 Game Engine

Thank you for your time !

Yes, this is “expected” behaviour. (I mean it may be surprising but is probably not a bug)

When you attach a rigidbody component to an entity the world transform of the entity is set by the rigidbody simulation. That means the rigidbody entities ignore parent transforms. So teleporting a parent rigidbody has no effect.

Couple of solutions:

  1. Teleport individual rigidbodies
  2. When an Entity is enabled the rigidbody transform is initialized from the Entity transform. So if you move while disabled the parent is disabled that may work
  3. There is a (private) API method called syncBodyToEntity() which can be used to force the rigidbody to get the transform from the entity positions.
1 Like