Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Best way to synchronise data between Gameobjects and Entities?

Discussion in 'Entity Component System' started by calabi, Jun 9, 2021.

  1. calabi

    calabi

    Joined:
    Oct 29, 2009
    Posts:
    232
    So I'm having to use Gameobjects with the Unity Navmesh stuff because there isn't really any completely viable pathfinding stuff in DOTS yet.

    So I'm trying to have most of the game made using DOTS and the parts like pathfinding and maybe other parts using GameObjects and Monobehaviours. So I'm curious what are the current best ways to get data to and from these gameobjects.

    Like I want to have a state system made in DOT's that stores and controls the gameobjects, like what they do and where they go. So I need to store there state and be able get that in entities and I need there position, and probably quite a few other variables that are stored in dots that synchronise with the behaviour of the gameobjects.

    I've seen things like Hybrid components I'm not really sure how to use them currently, or maybe I should use something like convert and inject. I dont know maybe its not a good idea in general to use gameobjects like this with dots? I'm not to bothered about performance currently I just want get something working maybe I could then transfer it fully to dots if there is ever a viable pathfinding for it.
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    There is few Navmesh solutions in DOTS, rolling about in the forum / git. Did you looked at them?
    Also Unity Navmesh is apparently supporting jobs. Some people been using it with DOTS.

    That could help reduce usage of GameObjects and complexity related to linking with entities, other than conversion to entities.
     
  3. calabi

    calabi

    Joined:
    Oct 29, 2009
    Posts:
    232
    Yeah I've seen some of those dots navmesh, and they are great but most aren't quite finished, and probably best not to rely on something that isn't finished and doesn't work quite as well as unitys yet(behaviour wise).

    I guess I could just store the data straight on the gameobject and get it in dots the same way I'm using the navmesh without conversion. Will have to see if it's viable for the number of objects I want.
     
  4. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    I found that a Monobehaviour that sends Transform data to Entities is faster than a System extracting transform data from GameObjects. Not sure why or how, but it was a gross difference, maybe my method was just that terrible. Don't have my old code nor I remember exactly how I did.
    So I will go out and assume that Monobehaviours updating Entities will be faster than the other way around at least some of the times.
     
  5. calabi

    calabi

    Joined:
    Oct 29, 2009
    Posts:
    232
    Thats interesting. I've done a simple comparison between code with every object updating its own direction on the navmesh, with a simple for loop iterating them on a system and its twice as fast in the system(2ms vs 4 I think). I'm curious how people are using the navmesh with jobs.

    I kind of just need a unique ID for each gameobject then I could use that to identify and correlate the entity component data with the gameobject, that might be the most efficient way.