diff --git a/Assets/Mirror/Core/Tools/Mathd.cs b/Assets/Mirror/Core/Tools/Mathd.cs
index af5d7b8a4..ddef15a36 100644
--- a/Assets/Mirror/Core/Tools/Mathd.cs
+++ b/Assets/Mirror/Core/Tools/Mathd.cs
@@ -5,6 +5,16 @@ namespace Mirror
{
public static class Mathd
{
+ // Unity 2020 doesn't have Math.Clamp yet.
+ /// Clamps value between 0 and 1 and returns value.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static double Clamp(double value, double min, double max)
+ {
+ if (value < min) return min;
+ if (value > max) return max;
+ return value;
+ }
+
/// Clamps value between 0 and 1 and returns value.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Clamp01(double value)