Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MB_SmoothLerper : MonoBehaviour
  5. {
  6.  
  7.     float SmoothLerp (float A, float B, float Rate)
  8.     {
  9.         if (A == B)
  10.             return A;
  11.         else if (A < B) {
  12.             if (A + (Rate * Time.deltaTime) >= B) {
  13.                 return B;
  14.             } else {
  15.                 return (A + (Rate * Time.deltaTime));
  16.             }
  17.         } else if (A > B) {
  18.             if (A - (Rate * Time.deltaTime) <= B) {
  19.                 return B;
  20.             } else {
  21.                 return (A - (Rate * Time.deltaTime));
  22.             }
  23.         } else {
  24.             return A;
  25.         }
  26.     }
  27.  
  28.     float SmoothLerp (float A, float B, float RateUp, float RateDown)
  29.     {
  30.         if (A == B)
  31.             return A;
  32.         else if (A < B) {
  33.             if (A + (RateUp * Time.deltaTime) >= B) {
  34.                 return B;
  35.             } else {
  36.                 return (A + (RateUp * Time.deltaTime));
  37.             }
  38.         } else if (A > B) {
  39.             if (A - (RateDown * Time.deltaTime) <= B) {
  40.                 return B;
  41.             } else {
  42.                 return (A - (RateDown * Time.deltaTime));
  43.             }
  44.         } else {
  45.             return A;
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement