Search Unity

Feature Request Ghost Prefab Variants?

Discussion in 'NetCode for ECS' started by l33t_P4j33t, Apr 21, 2021.

  1. l33t_P4j33t

    l33t_P4j33t

    Joined:
    Jul 29, 2019
    Posts:
    232
    Does something like this exist, or is in the works?
    ie. have ghosts that all sync the same ghost fields, but that have different materials, meshes, fields, etc.
    create the prefab variants in the unity editor, instead of having to manually create the permutations via code
     
    Last edited: Apr 21, 2021
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    895
    You can create prefab variants for the same "ghost" prefab. Internally they will be considered like ghosts types.

    The prefab variant (or a prefab duplicate) can also use different serialization for certain component using the GhostComponentVariantAttribute (see asteroid for an example, we use that for 2D translation and rotation for example)
     
    Last edited: Apr 21, 2021
  3. l33t_P4j33t

    l33t_P4j33t

    Joined:
    Jul 29, 2019
    Posts:
    232
    do the variants have to exist in the ghost collection? is it possible to, for example, load a prefab asset at runtime and instantiate it as a ghost?
    currently, the solution i have is to instantiate a generic ghost which is just an entity that has ghost fields, and then instantiate a prefab that represents the player. then copy the transforms, etc. from the ghost to the player character
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    895
    In general they must exist in the collection in order to be spawned as a ghost. The runtime need to know what entities prefabs are there in order to be able to instantiate them properly.

    If you want only differentiate materials, meshes etc, a possibility is to have just a base ghost with the replicated components. For the visual representation you may instantiate just another prefab entity, that it is not required to be a ghost, in that case and link then using LinkedEntityGroup for example.