How to set up a conversion system that runs after PhysicsCollider conversion?

I need a conversion system that can run after the PhysicsCollider is created, so that I can ensure some properties on the PhysicsCollider are set correctly. I do it like this:

[UpdateAfter(typeof(EndColliderConversionSystem))]
    public class MyConversionSystem : GameObjectConversionSystem
    {
        protected override void OnUpdate()
        {
            Entities.ForEach((MyAuthoring authoring) =>
            {
                Entity entity = GetPrimaryEntity(authoring);
                PhysicsCollider physicsCollider = EntityManager.GetComponentData<PhysicsCollider>(entity);

                // set properties on physicsCollider, etc....
            });
        }
    }

However, this gives me the following error on the line where we try to get the PhysicsCollider component:

The gameobject being converted does have a PhysicsShapeAuthoring on it. What am I missing?

@PhilSA use GameObjectConversionSystem.DstEntityManager instead of ComponentSystemBase.EntityManager

3 Likes

awesome, that was it!

Be careful, if you change the Archetypes on static colliders at this stage, there are some constellations where they won’t be loaded correctly if this is in a subscene (that is not open for editing, i.e. fully serialized).