Guest User

Untitled

a guest
Dec 9th, 2019
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. // Hard held values go negative when we "eat" them into a flick or when they go over the hard dir interval, and then we don't zero/begin updating them until the hard input is released
  2. if (pushingInput > HardDirDeadzone) { if (hardUpHeld >= 0) { hardUpHeld += Time.deltaTime; } }
  3. else { hardUpHeld = 0f; }
  4. if (pushingInput < -HardDirDeadzone) { if (hardDownHeld >= 0) { hardDownHeld += Time.deltaTime; } }
  5. else { hardDownHeld = 0f; }
  6.  
  7. if (steeringInput > HardDirDeadzone) { if (hardRightHeld >= 0) { hardRightHeld += Time.deltaTime; } }
  8. else { hardRightHeld = 0f; }
  9. if (steeringInput < -HardDirDeadzone) { if (hardLeftHeld >= 0) { hardLeftHeld += Time.deltaTime; } }
  10. else { hardLeftHeld = 0f; }
  11.  
  12. // Then we convert those to flicks (and it "eats" the hard inputs, to avoid multi-frame flicks)
  13. if (Mathf.Abs(pushingInput) < HardDirDeadzone)
  14. {
  15. if (hardUpHeld > 0f) { lastUpFlick = Time.timeSinceLevelLoad; hardUpHeld = -1f; Debug.Log("up flick"); }
  16. if (hardDownHeld > 0f) { lastDownFlick = Time.timeSinceLevelLoad; hardDownHeld = -1f; Debug.Log("down flick"); }
  17. }
  18.  
  19. if (Mathf.Abs(steeringInput) < HardDirDeadzone)
  20. {
  21. if (hardRightHeld > 0f) { lastRightFlick = Time.timeSinceLevelLoad; hardRightHeld = -1f; Debug.Log("right flick"); }
  22. if (hardLeftHeld > 0f) { lastLeftFlick = Time.timeSinceLevelLoad; hardLeftHeld = -1f; Debug.Log("left flick"); }
  23. }
  24.  
  25. // Eat any hard dir holds that have gone over the interval (now they're just holds, nothing hard about them)
  26. if (hardUpHeld >= HardDirInterval) { hardUpHeld = -1f; }
  27. if (hardDownHeld >= HardDirInterval) { hardDownHeld = -1f; }
  28. if (hardRightHeld >= HardDirInterval) { hardRightHeld = -1f; }
  29. if (hardLeftHeld >= HardDirInterval) { hardLeftHeld = -1f; }
Advertisement
Add Comment
Please, Sign In to add comment