[Mathematics] Search for some Mathf features

I’am currently upgrading a old project to the Unity.Mathematics System to Burst Compile.

I search the Mathf.PingPong Function, is there something available?

Later i will add other searches here, so if someone can’t find Functions from the old Mathf in the new Mathematics, let me know.

Thanks

There’s a few useful ported functions here (not pingpong)

such as SmoothDampnalge, Repeat, DeltaAngle, MoveTowards, LerpAngle etc etc

You can always port directly from Mathf. Either by decompiling, or you can find decompiled sources, e.g.:

As for the PingPong method, here it is:

// PingPongs the value t, so that it is never larger than length and never smaller than 0.
public static float PingPong(float t, float length)
{
    t = Repeat(t, length * 2F);
    return length - Mathf.Abs(t - length);
}
1 Like

Thank you that is what i searched for, i can change the Mathf.Abs function to the new Mathematics.Abs function, to get it Burst ready :smile: