Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Dash()
- {
- playerPos = new Vector3(Player.position.x, Player.position.y, 0f);
- dashTo = new Vector3(Player.position.x + maxDistance, Player.position.y, 0f);
- dashLeft = new Vector3(Player.position.x + -maxDistance, Player.position.y, 0f);
- if (Input.GetButtonDown("dash") && facingRight && !dashing)
- {
- if (grounded)
- {
- StartCoroutine(Move(playerPos, dashTo, dashAc, maxDistance / 4.1f));
- }
- if (!grounded && airdash <= 0)
- {
- StartCoroutine(Move(playerPos, dashTo, dashAc, maxDistance / 4.1f));
- airdash += 1;
- }
- if (!grounded && airdash > 0)
- {
- return;
- }
- }
- IEnumerator Move(Vector3 pos1, Vector3 pos2, AnimationCurve ac, float time)
- {
- float timer = 0.0f;
- while (timer <= time)
- {
- transform.position = Vector3.Lerp(pos1, pos2, ac.Evaluate(timer / time));
- timer += Time.deltaTime;
- //dashing = true;
- yield return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement