var tempBoidPositionArray = m_BoidQuery.ToComponentDataArray<BoidPositionComponent>(Allocator.Temp);
NativeArray<float3> boidPositions = new NativeArray<float3>(boidCount, Allocator.Temp);
Entities.With(m_BoidQuery)
.ForEach((
ref BoidVelocityComponent movementVelocityComp,
ref BoidPositionComponent boidPositionComp) => {
boidPositions[entityIndex] = tempBoidPositionArray[entityIndex].position;
});
Right now I do not know how to get the current entities index to make this happen
Use int entityInQueryIndex
as described in https://docs.unity3d.com/Packages/com.unity.entities@0.14/manual/ecs_entities_foreach.html#special-named-parameters.
Entities.With(m_BoidQuery)
.ForEach((
int entityInQueryIndex,
ref BoidVelocityComponent movementVelocityComp,
ref BoidPositionComponent boidPositionComp) => {
boidPositions[entityInQueryIndex] = tempBoidPositionArray[entityInQueryIndex].position;
});
The problem I get with using int entityInQueryIndex is that get the following error:
EntityQueryBuilder.F_E does not take 3 arguments
Use SystemBase, not ComponentSystem.
1 Like
My bad, I assumed you were using SystemBase.
No problem. All is well. Nice to have something simple fix my frustration
1 Like