浏览代码

Added SuperLerp function

James Peret 2 年之前
父节点
当前提交
bd011c6adc
共有 1 个文件被更改,包括 10 次插入2 次删除
  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;
+        }
     }
 }