[0.2.5.preview.1 + NetCode] Build Physics World Does Not Pick Up PhysicsVelocity Component

tl;dr Entity with PhysicsVelocity+Translation+Rotation components is not picked up by BuildPhysicsWorld#
DynamicEntityGroup query.

This issue occurs in 0.2.5.preview.1 in the Server World (NetCode), but to my knowledge did not occur in earlier versions. I believe it also did occur outside NetCode.

I have a weird issue where the DynamicEntityGroup in BuildPhysicsWorld is empty because I have no PhysicsVelocity components, even though I have GOs in the scene which have a Physics Body authoring component with Motion Type dynamic.

This then results in a failure in the CreateJoints method, because [CreateJoints] pair.BodyAIndex: -1, pair.BodyBIndex: -1.

As usual, the issue occurs in my example car (are you sick of it already? :smile::(), where I have four wheels which are connected to the main car body via joints, and they are in a parent-child relationship with the main body. Each wheel has a Physics Body authoring component.

When I start paused play mode, after clicking step once, the BuildPhysicsWorld system appears, but finds 0 dynamic bodies, since none of the wheels appear to have a PhysicsVelocity (or Translation or Rotation) component, according to the BuildPhysicsWorld system.

When I add a cube to the scene with a Physics Bodyauthoring component with Motion Type dynamic it receives a PhysicsVelocity component normally.

So, with the cube, in the debugger, I have this situation:

Only the Cube is picked up in the BPW system as dynamic, but none of the wheels.

In the console, I am printing some information about what happens in the BPW system:

So it picks up the one dynamic body (the Cube), and then tries to find bodies for the joints, which it fails, because the only bodies are the Cube and the plane, but none of the wheels.

However, in the debugger, when I select a wheel (entity 24), it lists that it has all the needed components to be picked up by the BPW system as a dynamic body:

I am utterly confused – why would entity 24 with PhysicsVelocity+Translation+Rotation components not be picked up by BuildPhysicsWorld?

I am happy to try and compile a case, but wanted to first ask if this is a known issue and if perhaps there is an obvious mistake I am making…? (Especially since the debugger clearly shows entity 24 with the necessary components)

Cheers and thanks for any help!

An update:

I noticed that the entity debugger had somehow cached All Entities – after reclicking it, the wheels disappeared and I only saw:

This is the initial state – for some reason, the PhysicsJoints are already listed, but the wheels and the main car body are not.

Roughly 10 steps later, the wheels appear, but they do not have the original entity ID, so of course, the BuildPhysicsWorld system falls on its nose when trying to CreateJoints, since the joints still have the old entity IDs. For example, the joint with entity id 33 points to entity id 24 and entity id 5, which once were wheels, but now the wheels occupy ids 58 to 61.

I’m starting to think it may be connected to NetCode and that perhaps I may not be using these two correctly in combination. But even so, the fact that the joints at one point exist on their own is very curious…?

Sorry for the probably confused seeming post. I believe now that the Entity Debugger was giving me erroneous information, in addition to the issue that I am actually having. This weird combination did not help :smile:

Posted a bug report on the Entity Debugger feedback thread here: Entity Debugger feedback page-4#post-5372754 Pretty unsure if anyone still reads it…?

I hope I can try to isolate the above issue where physics bodies for joints are not found anymore in a bug report.

I’ve tried isolating the issue, and potentially found another issue: [Case 1211673] GhostPrefabBuffer Cube Processed in BuildPhysicsWorld

Also, I noticed that the Joints are not from Unity Physics, but it is code taken from a Physics team member – sorry about that, I forgot. This may explain why they behave differently to the other Physics components (they are in the world, while the other physics component entities are not). I’ll try to figure out why they are treated differently.