Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SmoothChange : MonoBehaviour {
  5.  
  6. [Header("Higher value = smoother")]
  7. public float smoothness = 0.3f;
  8.  
  9.  
  10. [Header("Debug")]
  11. public float currentValue = 0;
  12.  
  13. public float targetValue = 0;
  14.  
  15. private float velocity;
  16.  
  17. // Use this for initialization
  18. void Start () {
  19.  
  20. }
  21.  
  22. // Update is called once per frame
  23. void Update()
  24. {
  25.  
  26. if(currentValue != targetValue)
  27. currentValue = Mathf.SmoothDamp(currentValue, targetValue, ref velocity, smoothness);
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement