Search Unity

The future of a GameObjectEntity (or similar) workflow

Discussion in 'Entity Component System' started by mxmcharbonneau, Aug 26, 2019.

  1. mxmcharbonneau

    mxmcharbonneau

    Joined:
    Jul 27, 2012
    Posts:
    10
    I read in a lot of threads here and there that GameObjectEntity will eventually be deprecated in favor of ConvertToEntity. We've just started the development of our next game, and while the ECS way of doing things is great, it's not there yet. There's a bunch of built-in and asset store stuff that is only available as MonoBehaviours and Gameobjects.

    We'll probably convert a lot of stuff to ECS in development, but I'm pretty sure we'll need a way for both systems to work with each other, until the moment we ship. Now, the best way to deal with this is having a kind of GameObjectEntity workflow, having both IComponentData and Monobehaviours on some Entities, and systems being able to manipulate those. Either by using GameObjectEntity itself or calling EntityManager.AddComponentObject() manually. Is this bound to disappear?

    ConvertToEntity can be useful, but those are not real MonoBehaviours, it's only a conversion. Will the ECS get rid of GameObjectEntities and/or EntityManager.AddComponentObject() to become pure ECS only at some point in the short to medium term?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Add EntityManager.AddComponentObject() is a safe option to use. It is even used in the conversion flow so it's not feasable to remove it at any point in the next couple years.

    Assuming you manage all of game object ownership. Eg. if the entity is destroyed the game object is not automatically destroyed, your code will do that. Instantiate is also not expected to "just" work, you'll have to duplicate the game object and then add the instantiated component.

    We might do more but so far we found that it's very difficult to make those two worlds work together 100% seamlessly and moving control over it to user code might be better. It's something we are looking at, not 100% clear on what the result will be.
     
    psuong likes this.
  3. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    982
    Please don't remove GameObjectEntity yet. I've found that we can't easily port our current implementation to Entity Conversion. It seems like if we use conversion, we have to rewrite every system/managers we have to conform to it. It's just not a smart thing to do for us when the game is already too big.
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    You can use conversion system pretty much exactly the same as GameObjectEntity. What is GOE providing you?
     
    Last edited: Aug 27, 2019
  5. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    982
  6. mxmcharbonneau

    mxmcharbonneau

    Joined:
    Jul 27, 2012
    Posts:
    10
    GameObjectEntity is providing us a way to make a GameObject and its components visible to the ECS World. I plan on making a big part of our game in ECS, but some of it can't just be converted for now.

    For those things where I absolutely need GameObject and MonoBehaviours, I plan on making something like an hybrid of GameObjectEntity and ConvertToEntity to insert them in ECS. Some of my MBs will convert to IComponentData, the rest will be AddComponentObject'ed, then I'll make systems that will manage all of it.

    The thing I like about this strategy is that when some of my MBs will be ported to a usable version in ECS, it will already have a large part of it managed in ECS systems, and the refactoring will be smoother.
     
  7. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    I think the main problem here is, that ecs in current state is lacking everything other than the foundation. You don't have skin mesh renderer, you don't have animation, you don't have particle system and many more. It's simply impossible to make a game with pure ecs, it's just lacking too many things. So if you want to take the advantage of ECS, you have to somehow connect gameobject with the ecs entity together. I mean, the conversion work flow even won't work for static objects baked with lightmap.
    The conversion workflow won't work well if the needed basic build blocks are still missing, because... they are just missing, how can they be converted.
     
    futurlab_peterh likes this.
  8. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    This is why conversion has the option of injecting the game object.
     
  9. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Correct. Right now they are missing. As you can probably imagine, those pieces will be landing over the next coming months... In the order of whats most important in a game.

    Until then GameObjectEntity and inject game object etc is a reasonable way to already use Entities while the systems aren't there yet. From that perspective it should be clear why we look at GameObjectEntity as something temporary.
     
    Last edited: Aug 28, 2019
  10. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    Really glad to hear that more systems are coming in the next months, because DOTS is recently so deadly quiet which made me a little bit worried about the progress
     
  11. JooleanLogic

    JooleanLogic

    Joined:
    Mar 1, 2018
    Posts:
    447
    Wow! All those systems are only 1 month away! Thanks Joachim! lol.

    I'm always watching this forum but the core ecs has been stable for quite a while and I'm guessing many (me) are just waiting for them to start ecs'ifying various feature systems.
     
  12. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    I am sorry. I was trying to type months. Not month.
     
  13. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    982
    That's good to hear. I don't mind if there are no more updates to GameObjectEntity as long as it still works. We're heavily invested in it as far as our game is concerned.