First System
[BurstCompile]
public partial struct XXXXSystem : ISystem
{
private EntityQuery _entityQuery;
[BurstCompile]
public void OnCreate(ref SystemState state)
{
_entityQuery = SystemAPI.QueryBuilder()
.WithAll<LocalToWorld>().Build();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var physicsWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>();
state.Dependency = new XXXXJob
{
PhysicsWorld = physicsWorld,
}.Schedule(_entityQuery, state.Dependency);
}
[BurstCompile]
private partial struct XXXXJob : IJobEntity
{
public PhysicsWorldSingleton PhysicsWorld;
[BurstCompile]
public void Execute(in LocalToWorld localToWorld, in Entity entity)
{
UnityEngine.Debug.Log($"{entity.Index} version {entity.Version} #######{localToWorld.Position}");
}
}
}
Second System
[BurstCompile]
public partial struct ZZZZSystem : ISystem
{
private EntityQuery _entityQuery;
[BurstCompile]
public void OnCreate(ref SystemState state)
{
_entityQuery = SystemAPI.QueryBuilder().WithAllRW<LocalToWorld>()
.Build();
}
//[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var dt = SystemAPI.Time.DeltaTime;
state.Dependency = new ZZZZJob()
.ScheduleParallel(_entityQuery, state.Dependency);
}
[BurstCompile]
public partial struct ZZZZJob : IJobEntity
{
public void Execute(ref LocalToWorld localToWorld, in Entity entity)
{
UnityEngine.Debug.Log($"{entity.Index} version {entity.Version} ************{localToWorld.Position}");
}
}
}
Result
309 version 2 #######float3(5.27f, 1.682025f, -10.24f)
309 version 2 ************float3(5.27f, 1.57575f, -10.24f)
309 version 2 #######float3(5.27f, 1.57575f, -10.24f)
309 version 2 ************float3(5.27f, 1.518525f, -10.24f)
309 version 2 ************float3(5.270084f, 0.7530007f, -3.565054f)
309 version 2 #######float3(-1.003042f, 0.7530007f, -7.958806f)
309 version 2 ************float3(5.270084f, 0.7530007f, -3.565054f)
309 version 2 #######float3(-1.003042f, 0.7530007f, -7.958806f)
I will ask the entity to move for A while and then stop moving for a while. After the movement is stopped, LocalToWorld.position is still different, so it should not be the problem caused by the system order