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.

copy transform to game object proxy (with rotation + scale) skewed

Discussion in 'Physics for ECS' started by impulse_ctrl, Jan 23, 2021.

  1. impulse_ctrl

    impulse_ctrl

    Joined:
    Dec 20, 2019
    Posts:
    6
    hello,

    I wonder if anyone else has encountered this and could offer assistance. It's for the case of a DOTS physics shape where it's desirable to have a representative gameobject follow the physics shape (Convert And Inject Game Object). With transform scale all set to 1.0 or rotations all set to 0 it works fine. However if I set both the scale and rotation to another value then the rotation of representative gameobject will be skewed when I hit play.

    Inspector with 0.1 scale & no rotation, gameobject is aligned with entity:





    Inspector with 0.1 scale & 90 rotation, gameobject is skewed:



    If I pause and look at the transform of the gameobject, it’s skewed by -32.18 degrees.



    Thanks,
    Nate B.
     
    Last edited: Jan 23, 2021
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Hi @impulse_ctrl, are you maybe touching rotation in the "copy transform to game object proxy" or "game object entity" scripts?
    I tried adding a cube to HelloWorld scene in UnityPhysicsSamples and playing with scale/rotation, didn't notice anything unusual.
     
  3. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    GameObjectEntity
    and the associated scripts where depreciated a while back so I don't recommend using them. I found some discussion on the topic on this thread.
    Furthermore, Unity Physics bakes in scale at conversation time, removing dynamic bodies from any hierarchy and only updates the new root entities
    Translation
    and
    Rotation
    component data structs.
    CopyTransformToGameObjectProxy
    is definitely not going to work as you are expecting if the GameObject is still in a hierarchy and when scale, and more importantly skew, is involved in the transform matrix.

    If you need the functionality of an GameObject following an Entity it would be best to implement your own System. The Unity Physics Samples have a basic EntityTracker example system that does this. Drop on the EntityTracker script to your GameObject and use the 'Convert and Inject Game Object' Conversion Mode in 'Convert To Entity'.
     
    impulse_ctrl likes this.