Giter Site home page Giter Site logo

Comments (6)

zeroZshadow avatar zeroZshadow commented on June 5, 2024

There are currently plans to integrate with the conversion systems and provide this API, however it is currently not possible due to the required functionality being internal to the entities packages.

Due to the nature of SpatialOS networking there is no guarantee that we already have access to the Metadata component at the time we create the ECS entity.
If we want to "create" the entity once the Metadata has been checked out, we'd be too late as we now already have an ECS entity that is linked to the SpatialOS entity.

The solution is to spawn an entity with GameObjectConversionUtility.ConvertGameObjectHierarchy(), and somehow merge the new root entity with our already existing entity.
Sadly the functionality to copy all components from 1 entity to another, and remap any entity id's, is internal to the entities packages and cannot be accessed by us even through use of reflection.

We're looking for methods around this, but until then we won't have proper support for the conversion workflow.

from gdk-for-unity.

No3371 avatar No3371 commented on June 5, 2024

Are you talking about GameObject -> Entity conversion?
Unity already provide enough tools to convert GameObject to Entities, I see no benefits for you to reinvneting the wheel, cloning entities sounds more sensible for me, as it support games go for pure ECS .

I'm sorry for the issue being unclear, but I was talking about letting users directly provide their entity (ECS) to act as SpatialOS managed entity (ECS) prefab, so once Spatial start syncing a world entity (Spatial -sync-> ECS), it clones the provided entity (ECS) instead of create a empty entity (ECS).

I understand you have your design concerns, just out of curiosity, if you don't mind 😉 I'd like to know what makes it impossible to

  • use EntityManager.Instantiate() to clone an entity with desired ECS data
  • SpatialOS add all required components
  • (Nothing more to do, all components ready for systems to query)

instead of

  • EntityManager.CreateEntity() to create a empty entity
  • SpatialOS add all required components
  • Users query for new entities and add desired components then set components data.

from gdk-for-unity.

zeroZshadow avatar zeroZshadow commented on June 5, 2024

The issue is that, at the time of entity creation, you will have no information about what kind of entity it is. For example, you won't have the Metadata component. So how would you pick the prefab to convert into your new entity to add the Spatial OS components too?

from gdk-for-unity.

No3371 avatar No3371 commented on June 5, 2024

I agree with you what prefab to use would be the problem, I was aware of this when raising this issue.

Proposal

...

  • As current EcsViewSystem.AddEntity(EntityId) takes an EntityId, allowing users to register a (EntityId, Entity) to a dictionary in the EcsViewSystem maybe the most compatible way. Users would have to do this before they send the CreateEntity world commands.

...

Metadata is the natural choice for this case, I totally agree with that, at the same time I also feels your current design is pretty nice. That's why I mentioned the first idea: Since you are already offering ID reservations tools, It seems acceptable (just my opinion of course😁) to decide which Entity (ECS) to use in EcsViewSystem.AddEntity() by EntityId.

Changing existing signatures is not needed, and the flow looks okay:
-> Reserving a EntityId
-> (Optional) Set (EntityID, Entity) to EcsViewSystem
-> WorldCommands.CreateEntity

at the time of entity creation, you will have no information about what kind of entity it is

In this case, it would be the user'd already know all components (prefab's + spatial's) the entity would have at the time of sending the creation command.

Even we eventually can use Metadata, this EntityId approach can still used to override for individual entity. (What if a devloper does not want to tie prefab to Metatdata?)

What do you think? What cons do you see in the idea? Not saying that you should accept it, it's just me like to discuss with and learn from people working on big systems.

from gdk-for-unity.

zeroZshadow avatar zeroZshadow commented on June 5, 2024

In your example, only the worker that requests the entity spawn will know what prefab entity to use.
How do you propose other workers, such as clients, will create the ecs entity once they check out the newly created SpatialOS entity?

from gdk-for-unity.

No3371 avatar No3371 commented on June 5, 2024

Solid point, I totally missed that! Not I see what you meant there's no way to achieve this (with current systems). Thanks! 😃

from gdk-for-unity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.