Explorar el Código

Added SuperLerp function

James Peret hace 2 años
padre
commit
bd011c6adc
Se han modificado 1 ficheros con 10 adiciones y 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;
+        }
     }
 }