Search Unity

  1. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Get entity Up normal from rotation

Discussion in 'Data Oriented Technology Stack' started by Michael4CG, May 19, 2020.

  1. Michael4CG

    Michael4CG

    Joined:
    Aug 19, 2019
    Posts:
    101
    is there a mathematical way to get entity up normal from rotation instead of using LocalToWorld.Value.c1 ?
     
    Last edited: May 19, 2020
  2. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    7,462
    Michael4CG likes this.
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    1,508
    Code (CSharp):
    1. var up = math.mul(rotation, new float3(0f, 1f, 0f));
     
    Michael4CG likes this.
  4. Michael4CG

    Michael4CG

    Joined:
    Aug 19, 2019
    Posts:
    101
    Thank you very much guys !
    One more question please, Is there an alternative to Quaternion.Lerp in unity mathematics ?


     
  5. RecursiveEclipse

    RecursiveEclipse

    Joined:
    Sep 6, 2018
    Posts:
    149
    You might also consider LocalToWorld.Up, you don't mention why you need it the other way, but thought I'd mention.

    There is math.nlerp which takes quaternions and returns a normalized lerp.
     
    Michael4CG likes this.
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    2,279
    math.nlerp

    Code (CSharp):
    1. /// <summary>Returns the result of a normalized linear interpolation between two quaternions q1 and a2 using an interpolation parameter t.</summary>
    2. public static quaternion nlerp(quaternion q1, quaternion q2, float t)
    If you look at Quaternion.Lerp
    "Interpolates between a and b by t and normalizes the result afterwards."

    So they've just named it better this time.
     
    Michael4CG likes this.
  7. Michael4CG

    Michael4CG

    Joined:
    Aug 19, 2019
    Posts:
    101
    aw that's perfect many thanks !
     
  8. Michael4CG

    Michael4CG

    Joined:
    Aug 19, 2019
    Posts:
    101
    Because for some reason the value of LocalToWorld.Value.c1 change when changing NonUniformScale , It becomes smaller or larger depending on the scale.
     
unityunity