Search Unity

  1. We have added a sub-forum for DOTS Graphics. Please use the new space for related discussions.
    Dismiss Notice
  2. The 2021.2 beta is now available. To find out what's new, have a look at our 2021.2 beta blog post.
    Dismiss Notice
  3. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  4. Dismiss Notice

Help Wanted Where/How to store reference to multiple Entity prefabs for ghosts

Discussion in 'Data Oriented Technology Stack' started by Jawsarn, Oct 13, 2020.

  1. Jawsarn


    Jan 12, 2017
    How should one go about referencing spawnable entity prefabs accessed by ID? As far as I can read you shouldn't store EntityPrefabs in blobs. And directly using arrays doesn't seem to be allowed for Entities.

    My situation is that I have ghost entities which can have a larger number of visual representations by faction/skins etc.

    Additional follow up, if I wanted to load this memory efficient, like e.g. using subscenes for the different EntityPrefabs I guess, is there any goto way already of doing this without building your fully own resource managing system?

    Thanks for any insight.
    apkdev likes this.
  2. Enzi


    Jan 28, 2013
    I have completely eliminated any graphical representation on the ghost itself and I have deferred graphical ghost object spawning into another system that not only loads the model but other additional data that I didn't want synced.
    So, in my server spawn system after instantiating I then make a RPC call which has all the data (modelId, classId, stats, etc...)

    The RPC system on client then loads all the data and model onto the ghost. Downside is that the ghost is only visible and really ready after the RPC call and not the ghost spawn. As it's only for players I don't mind that much.
    For faster spawning ghosts I'd sync a model id.
    Last edited: Oct 14, 2020
    apkdev likes this.
  3. kanesteven


    Aug 30, 2018
    I am building a moba-like game and have similar needs.

    In attempting to solve this problem elegantly I have had three primary goals:
    • Art/designer-friendly workflow for setting up/testing Animators/SkinnedMeshRenderer
    • Create as few disparate sources of data as possible needed to instantiate an entity
    • Avoid using MonoBehaviors/Singletons to store/lookup data in systems
    To instantiate Entities by EntityPrefabReference
    Create component with members pointing to each PrefabEntity and access it is a singletoncomponent from jobs

    To instantiate client-side-only GameObjects for rendering / animation / audio
    Create authoring component that points to a GameObject's Transform.
    Authoring component wraps that reference in a SharedComponent that is attached to the Entity.
    Client-side system looks for Entities.WithAll<GOWrapper>.WithNone<GOInstance> and instantiates an instance of the references gameobject inside a IStateComponentData wrapper Component. This system also looks for Entities.WithAll<GOInstance>.WithNone<GOWrapper> to destroy the gameobjects associated with destroyed entities.

    I am happy to share actual code if that would be helpful as well. This problem is very awkward currently and I would LOVE to be informed of a better way but this is what I am using currently.

    Additionally, I wonder if most people are using client-side-only gameobjects to actually render their characters/animated stuff? I have just not found the current state of HybridRenderer and Animations to be worth the hassle for this stage of development. Again, I'd love someone to enlighten me if this is just wrong.