Search Unity

Pure ECS transform.up equivalent

Discussion in 'Entity Component System' started by Khujo, Oct 4, 2019.

  1. Khujo

    Khujo

    Joined:
    Feb 14, 2012
    Posts:
    9
    What is the way of figuring out a Transform.up and Transform.right equivalent in a pure ECS implementation?

    I've had success using math.forward to calculate forward vectors from Unity's translation and position components; however, I've been unable to get vector offsets that take my entities rotation into account.
     
  2. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Just get it from LocalToWorldConponent

    Code (CSharp):
    1.  
    2.    public struct LocalToWorld : IComponentData
    3.    {
    4.        public float4x4 Value;
    5.  
    6.        public float3 Right { get; }
    7.        public float3 Up { get; }
    8.        public float3 Forward { get; }
    9.        public float3 Position { get; }
    10.    }
     
  3. Khujo

    Khujo

    Joined:
    Feb 14, 2012
    Posts:
    9
    Too easy, thank you!