I’m trying to get the PhysicsJoints that Unity creates if I add a ConfigurableJoint to an Entity, so Unity will create 2 entities as a child with PhysicsJoints, I then created a PostBaking System, and in it I put a Debug to check how many childs entities there were inside these Components, and it shows 0, even though I can clearly see them in the Entities Hierarchy, here is the code below and the images
using System.Diagnostics;
using Unity.Burst;
using Unity.Entities;
using Unity.Physics;
using Unity.Transforms;
using static SyncPhysicsJointAuthoring;
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
[UpdateInGroup(typeof(PostBakingSystemGroup))]
partial struct SyncPhysicsJointBakingSystem : ISystem
{
//[BurstCompile]
public void OnUpdate(ref SystemState state)
{
foreach (RefRW<SyncPhysicsJointComponent> syncJoint in SystemAPI.Query<RefRW<SyncPhysicsJointComponent>>())
{
Entity mainEntity = syncJoint.ValueRO.thisEntity;
UnityEngine.Debug.Log($"Entity {mainEntity} has Child: {state.EntityManager.HasComponent<Child>(mainEntity)}");
if (state.EntityManager.HasComponent<Child>(mainEntity))
{
DynamicBuffer<Child> childBuffer = state.EntityManager.GetBuffer<Child>(mainEntity);
int jointCount = 0;
UnityEngine.Debug.Log($"Checking entity: {mainEntity}");
}
}
}
}