Search Unity

CopyTransformFromGameObject component not updating Translation component

Discussion in 'Entity Component System' started by Whitepot, Mar 14, 2019.

  1. Whitepot

    Whitepot

    Joined:
    May 19, 2017
    Posts:
    15
    I am working with a gameobject that is moved via a navmesh, I also have some pure systems that need to act on it's potion so I have a Translation component (which, as far as I am aware, is the recent rename of the position component that should have the same functionality) and a CopyTranformFromGameObject component attached to it as well.

    The navmesh side of things is working fine but when I try to use the translation's value I find it's value has not changed from where it was initially set (both in editor and in a functional sense as the pure system thinks the entity is still at it's original position), viewing the translation in the Entity Debugger also shows it's value not changing.

    I also tested CopyTransformFromGameObject with an empty game object with a translation component and a CopyTransformFromGameObject component with he same results if I moved the game object via the editor even in while in play mode

    This what can be seen in the entity debugger when the transform is at a random position
    upload_2019-3-14_16-37-6.png

    I didn't notice this happening before recently updating the Entities package but it's possible I just missed it previously. Is there something obvious I'm missing missing when it come to the interaction of these components?
     
    Last edited: Mar 15, 2019
  2. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    77
    Looking at the code it appears that now it just copies position and rotation to
    LocalToWorld
    components, which essentially hold a 4x4 matrix of the transform. There are also other systems that seem to copy stuff from Translation, Rotation and Scale components to these matrix components.
    Not sure how to simply get a Translation component to update without writing a custom system though
     
    Last edited: Mar 14, 2019
  3. Whitepot

    Whitepot

    Joined:
    May 19, 2017
    Posts:
    15
    So looking at the LocalToWorld component's documentation it has a position property. I haven't used LocalToWorld before so would changing my systems that currently use translation component to now use the LocalToWorld component work? I just need to get the gameobject's current position in a pure system.

    Edit: Just checked out an old build and It worked as expected, I don't see anything about Unity removing this functionality in the release notes so is this a bug?

    Edit 2: Just tried changing over to using LocalToWorld but the LocalToWorld proxy component is marked as deprecated so I'm really not sure what the best course of action is here

    Edit 3: CopyTransformToGameObject works as expected so it seems to be an issue just with CopyTranformFromGameObject
     
    Last edited: Mar 15, 2019
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
  5. Whitepot

    Whitepot

    Joined:
    May 19, 2017
    Posts:
    15
    I saw that but I still have the problem that the LocalToWorld proxy component is marked as deprecated, is there some other component I should be using for my gameObject entities?

    Also are the release notes on that Github repository the best source for changes between previews? It's what I've been keeping an eye on but this change to CopyTransformFromGameObject's behaviour with the translation component (which is stated to just be a rename of the position component rather than any structural changes so I expected it to work exactly the same) wasn't listed on it.
     
  6. mike_acton

    mike_acton

    Unity Technologies

    Joined:
    Nov 21, 2017
    Posts:
    110
    > ... is there some other component I should be using for my gameObject entities?
    Have a look at the samples. You can use the conversion utilities to create components and entities from your gameobject.
     
  7. Whitepot

    Whitepot

    Joined:
    May 19, 2017
    Posts:
    15
    Thanks for pointing me in the direction of the samples Mike. I had a look at the conversion utilities but I'm not sure if it helps with the specific problem I'm having.

    My gameObject is moved by a NavMeshAgent, so I need it to continue to exist as a gameObject. It seems that I can't use the ConvertToEntity Script that HelloCube_01_ForEach uses, since NavMeshAgent won't convert to ECS. I am currently using the GameObjectEntity script for for gameObjects that require a hybrid approach.

    The Rotation, Translation and LocalToWorld proxy components are all marked as deprecated (I had only noticed LocalToWorld was marked before but I now see that all are).

    I had been using these with things like CopyTransformFromGameObject, to be able to use traditional systems and ECS where I could (i.e navmesh for moving, and then also separately ECS - using the Translation - to check if it's in a specific place), but I'm unsure what I should replace these with, or how I should adjust my approach when I need to take a hybrid approach.