#Using BlobAssets with DOTS/ECS for a Tower Defense Game

1 messages · Page 1 of 1 (latest)

raw spade
#

Hi, I'm currently trying to wrap my head around DOTS & ECS.

I'm prototyping a tower defense game so I've got lots of entities that will share the same data (waypoints along a path from their spawn point all the way to the "exit"). I've tried making use of ISharedComponentData to store the waypoint positions (as a list of float3) but I couldn't manage (having a float3[] inside a ISharedComponentData didn't sit right for some reasons). Many paths can exist so all entities might not follow the same path.

So I've just encountered BlobAsset and they seem to be one of the right tools to use in this case but I'm wondering about how to actually use them, should I:

  • Store a BlobAssetReference (in a ISharedComponentData) that's created at bake time and Unity will figure that a lot of other entities share the same content hence use the same pointer thanks to some BlobAssetStore magic ?
  • Store a BlobAssetReference (in a ISharedComponentData ) from a map of BlobAssetReference (one BlobAssetReference for each waypoint array that represents a path) that's created at GameObjectConversion time ?
  • Do something else that's more idiomatic of BlobAsset and DOTS ?
raw spade
#

Just read that GameObjectConversionSystems have been deprecated in favor of baking, my question still stands, should I opt for option 1 (is it even correct ?) or is there another way ?

rotund sinew
#

Are you trying to do some optimization with ISharedComponentData? It will group entities in chunks by the value of the data in the ISharedComponentData. Most cases you simply need a normal IComponentData with a blobAsset for shared data. Since the blob is a pointer, you will not duplicate the memory, and will not fragment your entities.

raw spade
#

Ideally I'd like to have all the entities that follow path A each hold the same pointer to the list of waypoints that represent path A

sinful sierra
#

during baking if you use AddBlobAsset it will share the same blobasset between all entities that have memory identical blobs so all of these entities blobs will point to the same memory

raw spade