As above, job’s Execute method is called for each chunk in sequence.
Each chunk allows (TypeManager.MaximumChunkCapacity = 128).
If i have more than 128 entities, they will save in more than 1 chunk.
Now i want to trave all entity in fixed order on different devices, how can i do it ?
I use foreach, or job.Schedule. And i know i can’t use ScheduleParallel.
Chunk A : 1 - 128
ChunkB : 129 - 256
On PC : maybe foreach first trave ChunkA then ChunkB.
But on phone, trave Chunk B then ChunkA.
How can i keep this sequence on different device ?
Tl;dr Put them in an array during baking (e.g. DynamicBuffer) and iterate over that. Or grab the entities and sort them based on some deterministic criteria.
Is there any reason why you want to rely on this? Unity doesn’t really give any guarantees about entity layout in memory (across devices or app runs). It would all go out of sync immediately as the simulation moves things around. Your code should be agnostic to entity/chunk order by default.
Now i want to do a moba like game. So i use ECS + LockStep to do this.
If i use LockStep to simulate word in different devices, the first thing is to confirm sequence.
Otherwise client a chunk1 → chunk2 → chunk3 …
but client b chunkn → chunkm → chunk3 → chunk1 …