The Problem:
There is nothing like spending hours on your game, in my case the enemy logic, only to have it all break after doing a pull and merging my code with the latest changes. In my case, after doing the pull and merge, my enemy AI just refused to do damage to the player. I reached out to the player designer as I was deriving my health component and damage output from his base classes in order to see if any work had been done that I should know about. At the time, his answer was no. He believed the work he did would have no impact my enemy AI. He believed my issues lied within an anim notify but I knew the problem was something else.
To review, after doing a pull and merging, the enemy AI still operated as it should. It would patrol when it didn't see the player and rush to attack when it did. It even played the animations without an any issues except for the fact that it was no longer dealing damage. I began the rabbit hole deep dive, putting break points on any and all functions that I believed to the culprit.
After several hours, I had narrowed down the issue to a single if check. This if check was the final check prior to calling the apply damage function. For some reason none of the flags were getting set. After some more investigating, I noticed there were function calls on the base weapon class that would set the flags when called. I naturally added those function calls into my attack functions and we made some success as now the enemy AI would deal damage on the first swing but would stop after that. Once again I found myself stumped on what to do next.
The Solution:
Why is it the solution always seems so simple in retrospect. For context, in order to deal damage an isAnimating and isAttacking bool both need to be set to true and the collider cannot be within a list of ignore actors. The list of ignore actors is created with every attack to ensure that the collider only strikes the target once and not multiple times per swing. The bool values where easily solved with a function call, but what I found out was, after the enemy swung at the player the first time, the enemies sword was entered into the ignore actors list.
Low and behold, hidden deep within the code, there was yet another function that needed to get called when the attack had finished. A function that would clear out list of ignore actors allowing for follow attacks to deal damage. Upon noticing this, I thought to myself "It can't be that simple". After adding the function to my attack end, I compiled the code and tested... it worked. Roughly 8 hours of debugging and hunting for the issue , making changes thinking the problem was bigger then it actually was, was solved by adding 3 additional function calls to my enemy AI.
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.