Advertisement
dog22180

Untitled

Aug 6th, 2021
1,671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1.     void animate (){
  2.        
  3.         if (horizontal > 0 ) {
  4.         anim.SetBool("Run", true);
  5.         sr.flipX = false;
  6.         }
  7.         else if (horizontal < 0 ) {
  8.         anim.SetBool("Run", true);
  9.         sr.flipX = true;
  10.         }
  11.  
  12.         else {
  13.         anim.SetBool("Run", false);
  14.         }
  15.  
  16.         if(body.velocity.y > 1) {
  17.             anim.SetTrigger("Jump");
  18.         }
  19.         if(body.velocity.y < -1) {
  20.             anim.SetTrigger("Fall");
  21.         }
  22.  
  23.  
  24.     }
  25.     void playerJump (){
  26.         if (Input.GetButtonDown("Jump") && isGrounded) {
  27.             isGrounded = false;
  28.             body.AddForce(new Vector2(0f, 7f), ForceMode2D.Impulse);
  29.         }
  30.        
  31.     }
  32.  
  33.   void attack2 (){
  34.              if (Input.GetButtonDown("Fire2")) {
  35.                  anim.SetTrigger("Attack2");
  36.              }
  37.  
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement