So I’m trying to figure out what is the best way to port my path following code from OOP to ECS and I’m stuck. I have hundreds of agents following multiple different paths defined by waypoints and I don’t know how to represent this in ECS. I’m not sure how the waypoints should be stored (entities, NativeArrays,…?) and how can an agent efficiently query for the next waypoint on its current path. Any suggestions? (In my current OOP code, each agent has simply a list of waypoints that it follows)
I store my waypoints in a buffer array attached to the entity.
I think @tertle is on the right track with storing the way points in a buffer array of that entity. Now how would you share the same waypoints among multiple agents?
Buffer array is fine.
But personally, I would define max count of waypoints per entity and never change it.
You can have less, or equal amount of points to the max count.
If instead of buffer array, storing all way points of entities in single linear array, accessesed by offset index (entity), now you can easily access and share points between.