Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MB_SmoothLerper : MonoBehaviour
- {
- float SmoothLerp (float A, float B, float Rate)
- {
- if (A == B)
- return A;
- else if (A < B) {
- if (A + (Rate * Time.deltaTime) >= B) {
- return B;
- } else {
- return (A + (Rate * Time.deltaTime));
- }
- } else if (A > B) {
- if (A - (Rate * Time.deltaTime) <= B) {
- return B;
- } else {
- return (A - (Rate * Time.deltaTime));
- }
- } else {
- return A;
- }
- }
- float SmoothLerp (float A, float B, float RateUp, float RateDown)
- {
- if (A == B)
- return A;
- else if (A < B) {
- if (A + (RateUp * Time.deltaTime) >= B) {
- return B;
- } else {
- return (A + (RateUp * Time.deltaTime));
- }
- } else if (A > B) {
- if (A - (RateDown * Time.deltaTime) <= B) {
- return B;
- } else {
- return (A - (RateDown * Time.deltaTime));
- }
- } else {
- return A;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement