Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. private float Test1()
  2. {
  3. SimpleTimer.Create(3f, () =>
  4. {
  5. //Do something
  6. });
  7. }
  8.  
  9. //increase the pitch if 5 seconds have not elapsed since the last call. Otherwise return restarted pitch
  10. private static SimpleTimer _timer;
  11. private static float _currentPitch = 1f;
  12. private float GetPitch()
  13. {
  14. if (_timer == null)
  15. {
  16. _timer = SimpleTimer.Create(5f, () =>
  17. {
  18. _currentPitch = 1f;
  19. _timer = null;
  20. });
  21. }
  22. _timer.Restart();
  23.  
  24. _currentPitch = Mathf.Clamp(_currentPitch + 0.05f, 1f, 2f);
  25. return _currentPitch;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement