You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
644 B
C#
27 lines
644 B
C#
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
|
|
namespace Projectiles
|
|
{
|
|
public static class MathUtility
|
|
{
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static float Map(float inMin, float inMax, float outMin, float outMax, float value)
|
|
{
|
|
if (value <= inMin)
|
|
return outMin;
|
|
|
|
if (value >= inMax)
|
|
return outMax;
|
|
|
|
return (outMax - outMin) * ((value - inMin) / (inMax - inMin)) + outMin;
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static float Map(Vector2 inRange, Vector2 outRange, float value)
|
|
{
|
|
return Map(inRange.x, inRange.y, outRange.x, outRange.y, value);
|
|
}
|
|
}
|
|
}
|