Hi all, just wondering if someone knew of a way to perform nested Entities.ForEach eg to find find the nearest target entity for another entity.
When I try using SystemBase I get the error “Entities.ForEach Lambda expression has a nested Entities.ForEach Lambda expression. Only a single Entities.ForEach Lambda expression is currently supported.”
This post describes how to do it in SystemBase but GetArchetypeChunkComponentType no longer seems available.
I never knew this actually was possible at some point, but it wouldn’t be surprising if support for this was just removed intentionally in order to improve compilation times or make things simpler or whatnot
Instead, you could do:
Run a Entities.ForEach job whose purpose is to fill either a NativeList or a singleton DynamicBuffer with the data of entities of a certain archetype (the entities that you’d want to iterate on in your “inner loop”)
Run a second Entities.ForEach job that uses the list/dynamicBuffer of previous step to do the inner loop iteration
“EntityElement” would be a struct containing Entity + Translation, for example