Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SmoothChange : MonoBehaviour {
- [Header("Higher value = smoother")]
- public float smoothness = 0.3f;
- [Header("Debug")]
- public float currentValue = 0;
- public float targetValue = 0;
- private float velocity;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update()
- {
- if(currentValue != targetValue)
- currentValue = Mathf.SmoothDamp(currentValue, targetValue, ref velocity, smoothness);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement