Guest User

Untitled

a guest
Dec 9th, 2019
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 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 && hardUpHeld >= 0) { hardUpHeld += Time.deltaTime; }
  3. if (pushingInput < -HardDirDeadzone && hardDownHeld >= 0) { hardDownHeld += Time.deltaTime; }
  4.  
  5. if (steeringInput > HardDirDeadzone && hardRightHeld >= 0) { hardRightHeld += Time.deltaTime; }
  6. if (steeringInput < -HardDirDeadzone && hardLeftHeld >= 0) { hardLeftHeld += Time.deltaTime; }
  7.  
  8. // Then we convert those to flicks (and it "eats" the hard inputs, to avoid multi-frame flicks)
  9. if (Mathf.Abs(pushingInput) < HardDirDeadzone)
  10. {
  11. if (hardUpHeld > 0f) { lastUpFlick = Time.timeSinceLevelLoad; hardUpHeld = -1f; Debug.Log("up flick"); }
  12. if (hardDownHeld > 0f) { lastDownFlick = Time.timeSinceLevelLoad; hardDownHeld = -1f; Debug.Log("down flick"); }
  13.  
  14. hardUpHeld = hardDownHeld = 0f;
  15. }
  16.  
  17. if (Mathf.Abs(steeringInput) < HardDirDeadzone)
  18. {
  19. if (hardRightHeld > 0f) { lastRightFlick = Time.timeSinceLevelLoad; hardRightHeld = -1f; Debug.Log("right flick"); }
  20. if (hardLeftHeld > 0f) { lastLeftFlick = Time.timeSinceLevelLoad; hardLeftHeld = -1f; Debug.Log("left flick"); }
  21.  
  22. hardLeftHeld = hardRightHeld = 0f;
  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