Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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
- if (pushingInput > HardDirDeadzone) { if (hardUpHeld >= 0) { hardUpHeld += Time.deltaTime; } }
- else { hardUpHeld = 0f; }
- if (pushingInput < -HardDirDeadzone) { if (hardDownHeld >= 0) { hardDownHeld += Time.deltaTime; } }
- else { hardDownHeld = 0f; }
- if (steeringInput > HardDirDeadzone) { if (hardRightHeld >= 0) { hardRightHeld += Time.deltaTime; } }
- else { hardRightHeld = 0f; }
- if (steeringInput < -HardDirDeadzone) { if (hardLeftHeld >= 0) { hardLeftHeld += Time.deltaTime; } }
- else { hardLeftHeld = 0f; }
- // Then we convert those to flicks (and it "eats" the hard inputs, to avoid multi-frame flicks)
- if (Mathf.Abs(pushingInput) < HardDirDeadzone)
- {
- if (hardUpHeld > 0f) { lastUpFlick = Time.timeSinceLevelLoad; hardUpHeld = -1f; Debug.Log("up flick"); }
- if (hardDownHeld > 0f) { lastDownFlick = Time.timeSinceLevelLoad; hardDownHeld = -1f; Debug.Log("down flick"); }
- }
- if (Mathf.Abs(steeringInput) < HardDirDeadzone)
- {
- if (hardRightHeld > 0f) { lastRightFlick = Time.timeSinceLevelLoad; hardRightHeld = -1f; Debug.Log("right flick"); }
- if (hardLeftHeld > 0f) { lastLeftFlick = Time.timeSinceLevelLoad; hardLeftHeld = -1f; Debug.Log("left flick"); }
- }
- // Eat any hard dir holds that have gone over the interval (now they're just holds, nothing hard about them)
- if (hardUpHeld >= HardDirInterval) { hardUpHeld = -1f; }
- if (hardDownHeld >= HardDirInterval) { hardDownHeld = -1f; }
- if (hardRightHeld >= HardDirInterval) { hardRightHeld = -1f; }
- if (hardLeftHeld >= HardDirInterval) { hardLeftHeld = -1f; }
Advertisement
Add Comment
Please, Sign In to add comment