#Mapping Entity Index to corresponding index in same Chunk

1 messages · Page 1 of 1 (latest)

quiet marlin
#

Hello! I have several Entities which contain a "Target" ComponentData that points to another Entity in the same Chunk. Now, I am trying to process these Entities in an IJobChunk and having trouble converting the "Target" Entity.Index to a corresponding index in the NativeArrays created using chunk.GetNativeArray(). I know these entities are in the same chunk and are being processed in the same IJobChunk. How can I do this index mapping?

The Unity documentation suggests using EntityQuery.CalculateBaseEntityIndexArrayAsync() which would provide a baseChunkIndex. Then the conversion to/from chunk/Entity indices is just be Entity.Index - baseChunkIndex = chunk.index. But I get an IndexOutOfBounds exception when implementing this logic.

topaz skiff
#

chunk has a special method for that

quiet marlin
#

Is it a method of ArchetypeChunk? Only solution I see is to get the native array of entities and construct a mapping on chunk begin