public static float Abs(this float v) => Mathfs.Abs(v);
public static float Min(this Vector2 v) => Mathfs.Min(v.x, v.y);
public static float Min(this Vector4 v) => Mathfs.Min(v.x, v.y, v.z, v.w);
void Update() { if (!followTarget) { TrackPlayer(); return; } ResetCamWeights(); _trackingPos = Mathfs.MoveTowards(_trackingPos, followTarget.transform.position.y, smoothTime * Time.deltaTime); // We're above the topmost breakpoint, show topcam only if (_trackingPos > breakpoints[0]) { _virtualCam.m_Weight0 = 1.0f; return; } // Between cam1 and cam2, lerp. if (_trackingPos > breakpoints[1]) { var camWeights = BlendCameras(breakpoints[0], breakpoints[1], _trackingPos); _virtualCam.m_Weight0 = camWeights.Item1; _virtualCam.m_Weight4 = camWeights.Item2; _virtualCam.m_Weight1 = camWeights.Item3; return; } // In cam2. if (_trackingPos > breakpoints[2]) { _virtualCam.m_Weight1 = 1.0f; return; } // Between cam2 and cam3, lerp. if (_trackingPos > breakpoints[3]) { float t = Mathfs.Smoother01(Mathfs.InverseLerp(breakpoints[2], breakpoints[3], _trackingPos)); _virtualCam.m_Weight1 = 1.0f - t; _virtualCam.m_Weight2 = t; return; } // In cam3. if (_trackingPos > breakpoints[4]) { _virtualCam.m_Weight2 = 1.0f; return; } // Between cam3 and cam4, lerp. if (_trackingPos > breakpoints[5]) { var camWeights = BlendCameras(breakpoints[4], breakpoints[5], _trackingPos); _virtualCam.m_Weight2 = camWeights.Item1; _virtualCam.m_Weight4 = camWeights.Item2; _virtualCam.m_Weight3 = camWeights.Item3; return; } // We're below the bottommost breakpoint, show botcam only _virtualCam.m_Weight3 = 1.0f; }
public static Vector3 Clamp01(this Vector3 v) => new Vector3(Mathfs.Clamp01(v.x), Mathfs.Clamp01(v.y), Mathfs.Clamp01(v.z));
public static Vector3 Round(this Vector3 v) => new Vector3(Mathfs.Round(v.x), Mathfs.Round(v.y), Mathfs.Round(v.z));
private void Update() { _currentMoonPhase = Mathfs.SmoothDamp(_currentMoonPhase, _targetPhase, ref _moonPhaseVel, 1.0f, 0.7f); RenderSettings.skybox.SetFloat(MoonPhase, _currentMoonPhase); }
public static int FloorToInt(this float v) => Mathfs.FloorToInt(v);
public static int CeilToInt(this float v) => Mathfs.CeilToInt(v);
public static float Repeat(this float v, float length) => Mathfs.Repeat(v, length);
public static int Mod(this int value, int length) => (value % length + length) % length; // modulo public static int RoundToInt(this float v) => Mathfs.RoundToInt(v);
public static float Remap(this float v, float iMin, float iMax, float oMin, float oMax) => Mathfs.Remap(iMin, iMax, oMin, oMax, v);
public static float Clamp(this float v, float min, float max) => Mathfs.Clamp(v, min, max);
public static float Magnitude(this float v) => Mathfs.Abs(v);
public static Vector4 Ceil(this Vector4 v) => new Vector4(Mathfs.Ceil(v.x), Mathfs.Ceil(v.y), Mathfs.Ceil(v.z), Mathfs.Ceil(v.w));
public static float Frac(this float v) => v - Mathfs.Floor(v);
public static Vector2 Round(this Vector2 v) => new Vector2(Mathfs.Round(v.x), Mathfs.Round(v.y));
public static float Clamp01(this float v) => Mathfs.Clamp01(v);
public static Vector4 Round(this Vector4 v) => new Vector4(Mathfs.Round(v.x), Mathfs.Round(v.y), Mathfs.Round(v.z), Mathfs.Round(v.w));
public static Vector2 Floor(this Vector2 v) => new Vector2(Mathfs.Floor(v.x), Mathfs.Floor(v.y));
// Update is called once per frame void Update() { var elapsed = Time.time - startTime; text.text = $"{Mathfs.Floor(elapsed / 60)}:{Mathfs.Floor(elapsed % 60):00}:{Mathfs.Floor((elapsed % 1) * 1000):000}"; }
public static Vector3 Floor(this Vector3 v) => new Vector3(Mathfs.Floor(v.x), Mathfs.Floor(v.y), Mathfs.Floor(v.z));
public static Vector2 Clamp01(this Vector2 v) => new Vector2(Mathfs.Clamp01(v.x), Mathfs.Clamp01(v.y));
public static Vector4 Floor(this Vector4 v) => new Vector4(Mathfs.Floor(v.x), Mathfs.Floor(v.y), Mathfs.Floor(v.z), Mathfs.Floor(v.w));
public static Vector4 Clamp01(this Vector4 v) => new Vector4(Mathfs.Clamp01(v.x), Mathfs.Clamp01(v.y), Mathfs.Clamp01(v.z), Mathfs.Clamp01(v.w));
public static Vector2 Ceil(this Vector2 v) => new Vector2(Mathfs.Ceil(v.x), Mathfs.Ceil(v.y));
public static float Min(this Vector3 v) => Mathfs.Min(v.x, v.y, v.z);
public static Vector3 Ceil(this Vector3 v) => new Vector3(Mathfs.Ceil(v.x), Mathfs.Ceil(v.y), Mathfs.Ceil(v.z));
public static float Max(this Vector2 v) => Mathfs.Max(v.x, v.y);
public static float AtMost(this float v, float max) => Mathfs.Min(v, max);