Explorar o código

Added SuperLerp function

James Peret %!s(int64=2) %!d(string=hai) anos
pai
achega
bd011c6adc
Modificáronse 1 ficheiros con 10 adicións e 2 borrados
  1. 10 2
      Runtime/Utilities.cs

+ 10 - 2
Runtime/Utilities.cs

@@ -51,11 +51,11 @@ namespace KairoEngine.Utility
             return worldPosition;
         }
 
-        public static Vector3 GetMouseWorldPosition(int mouseColliderLayerMask)
+        public static Vector3 GetMouseWorldPosition(int mouseColliderLayerMask, float distance = 999f)
         {
             if(Camera.main == null) return new Vector3();
             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
-            if(Physics.Raycast(ray, out RaycastHit raycastHit, 999f, mouseColliderLayerMask))
+            if(Physics.Raycast(ray, out RaycastHit raycastHit, distance, mouseColliderLayerMask))
             {
                 return raycastHit.point;
             }
@@ -147,6 +147,14 @@ namespace KairoEngine.Utility
             }
             return points;
         }
+
+        public static float SuperLerp(float from, float to, float from2, float to2, float value) {
+            if (value <= from2)
+                return from;
+            else if (value >= to2)
+                return to;
+            return (to - from) * ((value - from2) / (to2 - from2)) + from;
+        }
     }
 }