Search Unity

How to binding GameObject's Tranform to Entity's Translation?

Discussion in 'Data Oriented Technology Stack' started by ThreeIce, Aug 15, 2019.

  1. ThreeIce

    ThreeIce

    Joined:
    Aug 15, 2019
    Posts:
    7
    I'm using ConvertToEntity. There are some components that I don't have the ability to change them. These components use Transform to work. And my ecs code use Translation to work.
    I found that when I change the value of Translation, the value of Tranform don't change. And when I change the value of Transform, the value of Translation don't change.
    So How can I make the value of them same?
    Or I should use GameObjectEntity? (GameObjectEntity doesn't have Translation component)
    Thanks.
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,559
    Add a CopyTransformToGameObject in your conversion
     
  3. ThreeIce

    ThreeIce

    Joined:
    Aug 15, 2019
    Posts:
    7
    But it depend on GameObjectEntity
     
  4. mnarimani

    mnarimani

    Joined:
    Mar 27, 2017
    Posts:
    184
    CopyTransform* only works if you want to copy in one-way. Either from translation to transform or transform to translation. It doesn't work both ways. If you want to sync them both ways, you need to manually copy position data between them.
    Look at the source code to see how CopyTransformToGameObject works and you will get a good idea of how you should implement it.
     
  5. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,369
    Tertle not told you about proxy. He told you about component, which not depend on any thing.