miwarnec / DOTSNET

Public DOTSNET issue tracker
20 stars 0 forks source link

Context-specific prefabs for Server, Client Proxy, Client Owner #30

Open shinyclef opened 3 years ago

shinyclef commented 3 years ago

Different archetypes are required for server and client entities, and even client owned entities.

Example, for a player entity:

The only way to do this now seems to be to add or remove components when things are spawned, rather than spawning the correct archetype in the first place.

gabrjt's comment on this in another issue: https://github.com/vis2k/DOTSNET/issues/2#issuecomment-664455371

gabrjt commented 3 years ago

I think 3 context-specific prefabs would also be a nice approach and less error prone. The prefab system registers a "prefab map", that could be a Prefab, or Scriptable Object, which has an ID and 3 kinds of prefabs: Server, Client Owner and Client Proxy, where those prefabs are optional depending if the entity should be converted only in the Server, or the Client and if it has an Owner version, for example. Those 3 prefabs would be converted to prefab entities.

This prefab map could be converted then to an Entity or BlobAsset, and when syncing it's ID, the Spawn logic could spawn one of the three prefab entities depending of the context.

Entities could also have references to the prefab maps for multiple reasons, like spawners for example. Blob Asset seems to be well suited for this case.

Radivarig commented 3 years ago

Thought the same, currently I'm using tagging to create client-only entities under the existing entity, but it requires adding the hierarchy required components to make it follow the parent and destroy with it.