private void CounterAttack()
 {
     counter += Time.deltaTime;
     if (counter > counterlimit)
     {
         counter      = 0;
         counterlimit = UnityEngine.Random.Range(2.1f, 4);
         crabState    = CrabState.Attack;
         anim.SetBool("Attack", true);
     }
 }
 private void WalkL()
 {
     rdb.MovePosition(transform.position - Vector3.right * 0.1f);
     if (Physics2D.Raycast(transform.position + Vector3.up * 0.5f, -Vector2.right, 1))
     {
         crabState = CrabState.WalkR;
     }
     if (!Physics2D.Raycast(transform.position + Vector3.up * 0.5f, new Vector2(-1, -1), 1))
     {
         crabState = CrabState.WalkR;
     }
     CounterAttack();
 }
 private void Attack()
 {
     counter += Time.deltaTime;
     if (counter > counterlimit)
     {
         counter = 0;
         anim.SetBool("Attack", false);
         if (UnityEngine.Random.Range(0, 100) > 50)
         {
             crabState = CrabState.WalkR;
         }
         else
         {
             crabState = CrabState.WalkL;
         }
     }
 }