public static FPQuaternion Slerp(FPQuaternion from, FPQuaternion to, FP t) { t = FPMath.Clamp(t, 0, 1); FP dot = Dot(from, to); if (dot < 0.0f) { to = Multiply(to, -1); dot = -dot; } FP halfTheta = FP.Acos(dot); return(Multiply(Multiply(from, FP.Sin((1 - t) * halfTheta)) + Multiply(to, FP.Sin(t * halfTheta)), 1 / FP.Sin(halfTheta))); }
public static void SmoothStep(ref FPVector2 value1, ref FPVector2 value2, FP amount, out FPVector2 result) { result = new FPVector2( FPMath.SmoothStep(value1.x, value2.x, amount), FPMath.SmoothStep(value1.y, value2.y, amount)); }
public static FPVector2 SmoothStep(FPVector2 value1, FPVector2 value2, FP amount) { return(new FPVector2( FPMath.SmoothStep(value1.x, value2.x, amount), FPMath.SmoothStep(value1.y, value2.y, amount))); }
public static void Min(ref FPVector2 value1, ref FPVector2 value2, out FPVector2 result) { result.x = FPMath.Min(value1.x, value2.x); result.y = FPMath.Min(value1.y, value2.y); }
public static FPVector2 Min(FPVector2 value1, FPVector2 value2) { return(new FPVector2( FPMath.Min(value1.x, value2.x), FPMath.Min(value1.y, value2.y))); }
public static void LerpUnclamped(ref FPVector2 value1, ref FPVector2 value2, FP amount, out FPVector2 result) { result = new FPVector2( FPMath.Lerp(value1.x, value2.x, amount), FPMath.Lerp(value1.y, value2.y, amount)); }
public static FPVector2 LerpUnclamped(FPVector2 value1, FPVector2 value2, FP amount) { return(new FPVector2( FPMath.Lerp(value1.x, value2.x, amount), FPMath.Lerp(value1.y, value2.y, amount))); }
public static void Hermite(ref FPVector2 value1, ref FPVector2 tangent1, ref FPVector2 value2, ref FPVector2 tangent2, FP amount, out FPVector2 result) { result.x = FPMath.Hermite(value1.x, tangent1.x, value2.x, tangent2.x, amount); result.y = FPMath.Hermite(value1.y, tangent1.y, value2.y, tangent2.y, amount); }
public static void Clamp(ref FPVector2 value1, ref FPVector2 min, ref FPVector2 max, out FPVector2 result) { result = new FPVector2( FPMath.Clamp(value1.x, min.x, max.x), FPMath.Clamp(value1.y, min.y, max.y)); }
public static FPVector2 Clamp(FPVector2 value1, FPVector2 min, FPVector2 max) { return(new FPVector2( FPMath.Clamp(value1.x, min.x, max.x), FPMath.Clamp(value1.y, min.y, max.y))); }
public static FPVector2 CatmullRom(FPVector2 value1, FPVector2 value2, FPVector2 value3, FPVector2 value4, FP amount) { return(new FPVector2( FPMath.CatmullRom(value1.x, value2.x, value3.x, value4.x, amount), FPMath.CatmullRom(value1.y, value2.y, value3.y, value4.y, amount))); }
public static FPVector2 Barycentric(FPVector2 value1, FPVector2 value2, FPVector2 value3, FP amount1, FP amount2) { return(new FPVector2( FPMath.Barycentric(value1.x, value2.x, value3.x, amount1, amount2), FPMath.Barycentric(value1.y, value2.y, value3.y, amount1, amount2))); }
// Returns the angle in degrees between /from/ and /to/. This is always the smallest public static FP Angle(FPVector from, FPVector to) { return(FPMath.Acos(FPMath.Clamp(Dot(from.normalized, to.normalized), -FP.ONE, FP.ONE)) * FPMath.Rad2Deg); }
// Update is called once per frame protected override void SpaxUpdate() { if (!stopTimer.IsTicking()) { StateConditions curCond = data.GetStateConditions(); //for holding change in velocity for faster access float accel = 0f; //holds the x-axis input for faster access int xInput = input.X(); //if there is a frame to apply some stuff, do it //if the state allows for gravity application if ((curCond & StateConditions.APPLY_GRAV) > 0) { if ((calcVelocity.y - data.GetGravForce()) <= (-1 * data.moveStats.maxFallSpeed)) { calcVelocity.y = -1 * data.moveStats.maxFallSpeed; } else { calcVelocity.y -= data.GetGravForce(); } } //read if the player wants to move if (xInput != 0) { //if the state allows for movement if ((curCond & StateConditions.CAN_MOVE) > 0) { bool isWalking = (curCond & StateConditions.WALKING) == StateConditions.WALKING; //hold the acceleration for quicker access accel = data.GetAcceleration(isWalking); //Debug.Log(isWalking+" | "+accel); if (FPMath.Abs(calcVelocity.x + accel * xInput) >= (FP)data.GetMaxSpeed(isWalking)) { calcVelocity.x = data.GetMaxSpeed(isWalking) * xInput; } else { calcVelocity.x += accel * xInput; } } } //if the state applies friction if ((curCond & StateConditions.APPLY_FRICTION) > 0) { //accel will be (at least) close to 0 if the player an and wants to move if (Mathf.Abs(accel) < 0.00001f) { //hold the friction for quicker access accel = data.GetFriction(); if ((FPMath.Abs(calcVelocity.x) - accel) <= 0f) { calcVelocity.x = 0f; } else { //multiply by normalized to counter the current velocity calcVelocity.x -= accel * calcVelocity.normalized.x; } } } //assign the new calculated velocity to the rigidbody rb.velocity = calcVelocity; //txt.text = data.GetStringPrevInputs(); } }
public static FPQuaternion Lerp(FPQuaternion a, FPQuaternion b, FP t) { t = FPMath.Clamp(t, FP.Zero, FP.One); return(LerpUnclamped(a, b, t)); }