Search Unity

Problem with debugger or with the script? I can't tell

Discussion in 'Scripting' started by Falcoshin, Oct 20, 2017.

  1. Falcoshin

    Falcoshin

    Joined:
    May 31, 2017
    Posts:
    168
    I'm trying to write an attack routine for a character. It certainly works as intended, but the problem is that the first time I launch the debugger after opening Unity it glitches out and doesn't work as it's suppose to:

    This is what it looks like the first time it's run after launching Unity:
    Code run.gif

    And this is what it looks like every time after so long as I don't close Unity:
    Code run 2.gif


    As you can see, the code DOES do what it's suppose to, but only under specific circumstances. The problem is that I can't find out what those circumstances actually are and how to fix them. If it helps, this is the attack script:

    Code (csharp):
    1.  
    2. protected override void attack()
    3.     {
    4.         if (comboAttack == 0 && anim.IsPlaying("Melee_attack3") == false)
    5.         {
    6.             anim.GetClip("Melee_attack").wrapMode = WrapMode.Once;
    7.             anim.Play("Melee_attack");
    8.             comboAttack++;
    9.         }
    10.         else if (comboAttack == 1 && anim.IsPlaying("Melee_attack") == false)
    11.         {
    12.             anim.GetClip("Melee_attack2").wrapMode = WrapMode.Once;
    13.             anim.Play("Melee_attack2");
    14.             comboAttack++;
    15.         }
    16.         else if (comboAttack == 2 && anim.IsPlaying("Melee_attack2") == false)
    17.         {
    18.             anim.GetClip("Melee_attack3").wrapMode = WrapMode.Once;
    19.             anim.Play("Melee_attack3");
    20.             comboAttack = 0;
    21.         }
    22.     }
    So is the problem the code or is it the debugger? and if it's the latter, will the problem manifest if run on a final build?
     
  2. johne5

    johne5

    Joined:
    Dec 4, 2011
    Posts:
    1,133
    Falcoshin, there is not enough here for us to figure out whats going on.
     
  3. Falcoshin

    Falcoshin

    Joined:
    May 31, 2017
    Posts:
    168
    What more do you need exactly?