#Should I use a dynamicbuffer or AddComponent?

1 messages · Page 1 of 1 (latest)

small quartz
#

I'm trying to learn DOTS and I want to make like an RTS game to figure it out. I want to grab a list of all units selected by the player so that I can edit their targetPos variable.

I know it has some performance effects if I use AddComponent to add a selected tag, so should I make a singleton buffer of all selected objects? I just want to know what the best coding practice is here.

turbid rivet
#

AddComponent will cause bad performance when:

  • used constantly without restraint
  • tanks the running jobs
    So if you plan it well it isn't that bad. You just have to understand what it does and its effects on the ECS world.
#

Because you're exploring ECS, my suggestion is experimenting with both approaches to understand pros/cons of each one for a particular situation.