Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Having problems with the pure ecs simple example

Discussion in 'Entity Component System' started by avvie, May 13, 2018.

  1. avvie

    avvie

    Joined:
    Jan 26, 2014
    Posts:
    74
    As with a lot of people i am trying to wrap my head around and learn the ecs.
    So my first stupid obstacle was here.
    ecs.png

    Now it seems to me that it should the cube in the scene should be rotating, of course it doesnt and i am pretty lost. Btw the system does come up in the "Used by systems" dropdown in the GameObjectEntity
     
    Last edited: May 13, 2018
  2. isbdnt

    isbdnt

    Joined:
    May 16, 2017
    Posts:
    35
    Try to remove CopyTransformFromGameObjectComponent.
     
    Last edited: May 14, 2018
    avvie likes this.
  3. avvie

    avvie

    Joined:
    Jan 26, 2014
    Posts:
    74
    Thanks a lot that worked like a charm!
    I was wondering if you could provide some of the reasoning behind why that worked, if possible?

    My reasoning was that the the copy from and to would be required to get the actual transform and then write it back.
    was it a priority problem for example ? or copy from overrides the copy to components?
     
  4. isbdnt

    isbdnt

    Joined:
    May 16, 2017
    Posts:
    35
    it was a priority problem. my solution is writing copy systems myself. copy transfrom from go, do some game logic like walk, then copy transfrom to go
     
    Last edited: May 14, 2018
  5. avvie

    avvie

    Joined:
    Jan 26, 2014
    Posts:
    74
    So in theory, no idea how to actually write this up, you can get the copy from and pass it as a dependency to your job?
    In which case you have perfect control.
    Is that possible?
     
  6. isbdnt

    isbdnt

    Joined:
    May 16, 2017
    Posts:
    35
    use UpdateInGroup/UpdateBefore/UpdateAfter attributes. I defined several groups which make my systems in order.
     
  7. mike_acton

    mike_acton

    Unity Technologies

    Joined:
    Nov 21, 2017
    Posts:
    110
    > CopyTransformFromGameObjectComponent

    The intent of this component is for the GO to "own" the transform. The entity transform matrix will update based on whatever is in the GO, so you shouldn't change it in ECS.

    However, if you just want the initial transform from the GO and then "take over" the transform matrix in ECS, there is CopyInitialTransformFromGameObjectComponent for that purpose.
     
    avvie likes this.
  8. avvie

    avvie

    Joined:
    Jan 26, 2014
    Posts:
    74
    Thanks for the clarification @mike_acton

    @isbdnt I get the approach, although it feels like are missing still. In any case I am still not familiar enough to start playing with dependencies though :D I have bigger things to tackle on the way of learning
     
  9. UCh

    UCh

    Joined:
    Nov 18, 2012
    Posts:
    29
    I just updated to preview 11 and at some point, suddenly, looks like CopyTransformToGameObjectSystem is executed before CopyInitialTransformFromGameObjectSystem, so now all the GameObjectEntities move to 0,0,0 without rotation when I enter play mode. When I look at the Entities package code, both systems have this tag:

    [UpdateBefore(typeof (EndFrameTransformSystem))]

    ...and nothing else, so looks like the order of execution is not enforced. That can explain why was working for a while and suddenly not.

    Anyone else got this?
     
  10. mike_acton

    mike_acton

    Unity Technologies

    Joined:
    Nov 21, 2017
    Posts:
    110
    Yes, I wasn't considering that you might want to use both of these together.
    Will change to constrain CopyInitialTransformFromGameObjectSystem to run before CopyTransformToGameObjectSystem.
     
    twobob and laurentlavigne like this.