viewimage.php?id=2abcdd23dad63db0&no=24b0d769e1d32ca73ced84fa11d0283162f18dd5505eb28abfc2607ab5687bd8b6c8d52d842ab654ed61669750b127674f64d9303a25c45f3fe2f374e3aa698a1a7ac5



왼쪽에 player를 클릭해놓고 움직이면 속도가 엄청빠름 아마 렉때문인듯

근데 player말고 다른오브젝트 클릭하고 움직이면 정상적임

player에 있는 콜라이더를 지우니까 정상속도로 다시 돌아오는데 콜라이더 하나때문에 이러는게 말이됨? 3d에서 콜라이더 엄청많이써도 렉 하나도 안걸렸는데 왜이러는거임???


public class PlayerCtrl : PlayerValueManager
{
    Rigidbody2D rigidbody;
    Animator animator;
    Vector2 movement;
    float MoveX;
    float currentAttackDelay;
    float currentComboTimer;
    float MoveY;
    int AttackCount = 1;
    enum PlayerDirect{Left,Right};
    public PlayerDirect playerDirect;
    bool isAttack = false;
    // Start is called before the first frame update
    void Start()
    {
       
        rigidbody = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
        
        
    }
    // Update is called once per frame
    void Update()
    {
        MoveCheck();
        AnimCheck();
        AttackInputCheck();
        AttackDelayDecrease();
        
               
    }
    void MoveCheck()
    {
        if(!animator.GetBool("isAttack"))
        {
         MoveX = Input.GetAxisRaw("Horizontal");
         MoveY = Input.GetAxisRaw("Vertical");

        
        rigidbody.velocity = new Vector2 (MoveX  ,MoveY ).normalized  *MoveSpeed * Time.deltaTime;
        }
        else
        {
            MoveX = 0;
            MoveY = 0;

            rigidbody.velocity = new Vector2(0,0);
        }
        
    }
    void AnimCheck()
    {
        if(MoveX == 0 && MoveY == 0)
        {
            animator.SetBool("isRunning" , false);
        }
        else
        {
            animator.SetBool("isRunning"true);
        }

        if(MoveX < 0)
        {
            transform.localScale = new Vector2(-3,3);
            playerDirect = PlayerDirect.Left;
        }
        else if(MoveX > 0)
        {
            transform.localScale = new Vector2(3,3);
            playerDirect = PlayerDirect.Right;
        }
        
        
           
        

        if(EndCheckAnimation("AttackMotion"))
            animator.SetBool("isAttack" , false);

      
    }
    
    void AttackInputCheck()
    {
        if(Input.GetKeyDown(KeyCode.X) && currentAttackDelay < attackDelay && !isAttack )
        {
            if(AttackCount >= 5 )
            {
                AttackCount = 1;
            }
            StartCoroutine(Attack());
        }
    }
    bool EndCheckAnimation(string animationName)
    {
        return 
        animator.GetCurrentAnimatorStateInfo(0).IsTag(animationName) &&
        animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.99f;
    }
    void AttackDelayDecrease()
    {
        currentAttackDelay -= Time.deltaTime;
        currentComboTimer -= Time.deltaTime;

        if(currentComboTimer < 0)
        AttackCount = 1;
    }
    IEnumerator Attack()
    {
        isAttack = true;
        animator.SetBool("isAttack"true);      
        
        AttackMotionSelect();
        yield return new WaitForSeconds(attackDelay);
               
        AttackCount++;
        currentAttackDelay = attackDelay;
                      
        isAttack = false;
    }
    
    void AttackMotionSelect()
    {
        if(AttackCount == 1)
        {
            animator.Play("Player_Attack1");
            currentComboTimer = comboAttackTime;
        }
        else if(AttackCount == 2)
        {
            animator.Play("Player_Attack2");
            currentComboTimer = comboAttackTime;
        }
        else if(AttackCount == 3)
        {
            animator.Play("Player_Attack3");
            currentComboTimer = comboAttackTime;
        }
        else if(AttackCount == 4)
        {
            animator.Play("Player_Attack4");
        }
    }
    
}