Hello guys.
I’m trying to make a system that can generate a pack of hierarchy entities. Root entity has LinkedEntityGroup component, child entities have PhysicsShape colliders. When I call instantiate entity from prefab, it creates all entities from this pack but without child/parent relations. But if I add some collider on the parent entity - everything works just fine, child entities follow the parent entity, when it moves. What kind of magic is that?
root entity:
child entity:
A little bit more info:
Entities version 1.0.11
Code that instantiate the root entity (with child entities inside it):
public partial struct RoadSpawnJob : IJobEntity {
public EntityCommandBuffer Ecb;
public void Execute(
Entity entity,
ref RandomComponent random,
in DynamicBuffer<RoadSpawnerBufferComponent> spawner,
in LocalTransform transform
) {
...
Entity spawnedEntity = Ecb.Instantiate(spawner.Prefab);
...
}
}
public partial struct RoadSystem : ISystem {
public void OnCreate(ref SystemState state) {
state.RequireForUpdate<EndSimulationEntityCommandBufferSystem.Singleton>();
}
public void OnUpdate(ref SystemState state) {
EntityCommandBuffer ecb = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>().CreateCommandBuffer(state.WorldUnmanaged);
...
new RoadSpawnJob {
Ecb = ecb
}.Schedule();
...
}
}