Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. void Dash()
  2.     {
  3.         playerPos = new Vector3(Player.position.x, Player.position.y, 0f);
  4.         dashTo = new Vector3(Player.position.x + maxDistance, Player.position.y, 0f);
  5.         dashLeft = new Vector3(Player.position.x + -maxDistance, Player.position.y, 0f);
  6.  
  7.        
  8.        
  9.  
  10.         if (Input.GetButtonDown("dash") && facingRight && !dashing)
  11.         {
  12.            
  13.  
  14.             if (grounded)
  15.             {
  16.                 StartCoroutine(Move(playerPos, dashTo, dashAc, maxDistance / 4.1f));
  17.                
  18.             }
  19.  
  20.  
  21.             if (!grounded && airdash <= 0)
  22.             {
  23.                 StartCoroutine(Move(playerPos, dashTo, dashAc, maxDistance / 4.1f));
  24.                 airdash += 1;
  25.  
  26.             }
  27.  
  28.             if (!grounded && airdash > 0)
  29.             {
  30.                
  31.                 return;
  32.             }
  33.  
  34.            
  35.         }
  36.  
  37.  IEnumerator Move(Vector3 pos1, Vector3 pos2, AnimationCurve ac, float time)
  38.     {
  39.        
  40.         float timer = 0.0f;
  41.         while (timer <= time)
  42.         {
  43.             transform.position = Vector3.Lerp(pos1, pos2, ac.Evaluate(timer / time));
  44.             timer += Time.deltaTime;
  45.             //dashing = true;
  46.  
  47.             yield return null;
  48.         }
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement