Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class BattleSystem : MonoBehaviour
  7. {
  8.     Animator animator;
  9.  
  10.     public int anim = 0;
  11.  
  12.     void Start()
  13.     {
  14.         animator = GameObject.Find("Player").GetComponent<Animator>();
  15.     }
  16.  
  17.     void Update()
  18.     {
  19.         anim = animator.GetInteger("animation");
  20.         if (Input.GetMouseButtonDown(0))
  21.         {
  22.             ComboCheck();
  23.         }
  24.     }
  25.  
  26.     private void ComboCheck()
  27.     {
  28.         if (animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
  29.         {
  30.             animator.SetInteger("animation", 2);
  31.         }
  32.  
  33.         if (animator.GetCurrentAnimatorStateInfo(0).IsTag("Attack") && animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.85f)
  34.         {
  35.             if (animator.GetInteger("animation") == 4)
  36.             {
  37.                 animator.SetInteger("animation", 2);
  38.             }
  39.             else
  40.             {
  41.                 animator.SetInteger("animation", animator.GetInteger("animation") + 1);
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement