New to DOTS; I am trying create a boid-like system using entities that follow gameobjects. How can I communicate the position of the gameobjects and the information of other boid members to the entity systems or jobs. (Or, more generally, just any other kind of data?)
I have seen some mentions of singletons being accessible in systembase systems? Unfortunately doesn’t seem plausible for this specific problem as I will have a dynamic number of boid ‘groups’ at runtime that I want separate from each other - but it would still be good to know how to do this.
The general principle is to avoid accessing managed objects while a system is processing.
You will want to gather all the information you need in a separate up-front step. Most likely this will require that part of the code to run on the main thread. The output would be a native collection with just the value-type data that you need, and ideally Mathematics types eg float3 position values.
For a boid system you could implement that solely with a IJobParallelForTransform, avoiding Entities altogether if all you really need is the boid system.
I remember Unity had a (Unite?) talk that was primarily about the ECS-MB interaction. It was some sort of 2d top-down simplified example game. Not the ECS intro from this year’s Unite though.
Best I could find was this one tapping into the subject but it isn’t the one I was looking for: