Fixed the bug in "Bugs? What bugs?" but in the wrong way problably

I tought the bug was caused by the “stopAttacking” trigger getting activated after an attack and staying active after moving, which is actually what I still think the bug is. So I did try to reset the trigger by adding a "Animator.ResetTrigger(“stopAttacking”) right before the MoveTo(destination); instruction in the Mover script. But then the animation wouldn’t get cancelled when moving away while attacking, yet somehow, resetting the “attack” trigger does the job. The character correctly stops attacking when moving away and at the same time the “canAttack” trigger doesn’t stay active. It works perfectly but I know this wasn’t the correct solution I was supposed to implement. Most problably I had to reset the trigger somewhere else.

I’ll proceed with the course now and I’ll correct my code with the correct solution, because most problably what I did is going to cause problems in the future (otherwise why implement the “stopAttacking” trigger in the first place if we could just have done this?)

The only “wrong” ways are approaches that don’t work. There are many ways to the same result, we just show you one of them generally.

I ResetTrigger() all of my triggers immediately before Setting them. StopAttack, I actually reset twice: Once before setting Attack (in case one is stuck on, we don’t want the attack just aborting), and once before setting StopAttack

I was worried because sometimes you change something to fix a bug, then you find it works and proceed with the next thing, but you don’t know that you did create a new bug because you fixed the old one in the wrong way.

Anyways, I’m trying every possible challenge from the course, but then I change everything to be exactly as the lecture says, to make it easier to follow things later, as they usually reference old code when creating new ones.

That’s generally a good idea. What I tend to do with courses in general is to create two projects. One follows the course code. This makes it easier, if there’s an issue, for the instructor to assist. The other is my optimized project, where I reach for a better solution.

I am a beginner so I give it for sure that what the instructor does is better than anything I can think for myself

Privacy & Terms