Search Unity

Question Unity.Mathematics usage

Discussion in 'Package Manager' started by Birgere, Nov 22, 2021.

  1. Birgere

    Birgere

    Joined:
    Feb 8, 2016
    Posts:
    22
    Is the new math package meant to replace the old unity Mathf library? If so, how would I go about using it (since it doesn't support Vectors)?
     
  2. LogicFlow

    LogicFlow

    Joined:
    Aug 18, 2018
    Posts:
    33
    Unity.Mathematics does supply vector types, in formats like
    int4
    (a 4 component integer-based vector) or
    float3x4
    (a 12-component floating point matrix).

    However it is not a necessity for everyone to use. The new math package is intended for use by those familiar with existing GPU languages and SIMD APIs, and specifically for those who need serious low-level optimisation, since it makes use of the Burst compiler a lot easier; the reason for that being that with Unity.Mathematics, you don't need to either (a) rely on Burst's finnicky auto-vectoriser, or (b) code in Burst (AVX / SSE / Neon) intrinsics by yourself, which involves a lot of fine detail and platform-specific choices, which is enough to test most people's sanity.

    If you want to keep your life simple and get on with developing your ideas, carry on using the existing Mathf libaries unless and until you need the new math.

    Of course if you are intending to gravitate fully towards newer DOTS standards ASAP, and learning is more important than doing, then you may wish to start learning Unity.Mathematics, but even for DOTS, it is optional.
     
    Last edited: Dec 14, 2021