Created
August 21, 2022 11:57
-
-
Save Mazday21/5111343cb730093c0dd18783beba694a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerator Jump() | |
{ | |
_animator.SetBool("Grounded", false); | |
_coroutineAllowed = false; | |
_swipeTime = 0; | |
Vector3 startPosition = transform.position; | |
Vector3 endPosition = new Vector3(startPosition.x, transform.position.y + _jumpHeight, transform.position.z + _speed * _jumpDuration); | |
while (_swipeTime < _jumpDuration / 2) | |
{ | |
_swipeTime += Time.deltaTime; | |
transform.position = Vector3.Lerp(startPosition, endPosition, _swipeTime / _jumpDuration); | |
yield return null; | |
} | |
StartCoroutine(JumpDown()); | |
} | |
private IEnumerator JumpDown() | |
{ | |
_swipeTime = 0; | |
Vector3 startPosition = transform.position; | |
Vector3 endPosition = new Vector3(startPosition.x, transform.position.y - _jumpHeight, transform.position.z + _speed * _jumpDuration); | |
while (_swipeTime < _jumpDuration / 2) | |
{ | |
_swipeTime += Time.deltaTime; | |
transform.position = Vector3.Lerp(startPosition, endPosition, _swipeTime / _jumpDuration); | |
yield return null; | |
} | |
_animator.SetBool("Grounded", true); | |
_coroutineAllowed = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment