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. Dismiss Notice

Bug Transform Issues

Discussion in 'Entity Component System' started by piginaust, Dec 16, 2022.

  1. piginaust

    piginaust

    Joined:
    May 23, 2022
    Posts:
    14
    I updated from 1.0.0 pre.12 to 1.0.0 pre 15.

    So, the transform requires update. However, I encounter an issue.

    Code (CSharp):
    1.  
    2. ECBSystem.SetComponent(chunkIndex, enemy, new WorldTransform{Position = new float3(45, 1, 45)});
    For the above code, using worldtransform, the enemy appears at 1,1,1, roughly there, not the 45, 1, 45 position.

    Code (CSharp):
    1. ECBSystem.SetComponent(chunkIndex, enemy, new LocalTransform{Position = new float3(45, 1, 45)});
    If I put Local Transform, then NAN.

    Please see first picture. All positions, including LTW and rotations are NAN.

    If we put both WorldTransform and Local Transform, whichever order will result in error also.

    See second picture.

    Except for rotation and scale, all positions are NAN.

    Am I missing something?

    Btw, I don't see how this new Transform system is better.

    For the player to initiate a bullet, in pre 12 version, I just set translation = transform.position, rotation = transform.rotation, the bullet can be instantiated in front of the player.

    Now, I have to do two things still:

    Set WorldTransform.Position to player's transform position, scale at 1
    Set local transform.rotation to player's rotation.

    Yes, needs to set both world and local transform to achieve the same effect although I am setting a bullet without any child object!!!!
     

    Attached Files:

  2. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    282
    You were always doing this wrong.
    -Both WorldTransform and LocalTransform should be present.
    -Only LocalTransform should be written to.
    -ITransformData should always have a valid scale and a valid rotation quaternion.

    https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/transforms-using.html
     
  3. piginaust

    piginaust

    Joined:
    May 23, 2022
    Posts:
    14
  4. piginaust

    piginaust

    Joined:
    May 23, 2022
    Posts:
    14
    Btw, then is this a bug?

    Code (CSharp):
    1. ECBSystem.SetComponent(chunkIndex+1, e, new LocalTransform {_Position = new float3(45, 1, 45), _Rotation = playerAttack.GetRotation, _Scale = 1f});
    In this way, the launch position is not the one I set. It is still (0, 0, 0).

    Code (CSharp):
    1. ECBSystem.SetComponent(chunkIndex+1, e, new LocalTransform {_Position = new float3(45, 1, 45), _Rotation = playerAttack.GetRotation, _Scale = 1f});
    2. ECBSystem.SetComponent(chunkIndex+1, e, new WorldTransform {Position = new float3(45, 1, 45)});
    If I set worldtransform also, the launch position is (45, 1, 45).