Character not attacking when attack is pressed

When I press attack, the character doesn’t move, and then the game exits out of play mode and prompts me with an error in the console. This only happens when I choose to attack the (enemy) slime twice. It clearly shows in the console via debug log that the battle has started, and I am attacking the slime.

Note, when the game starts, the character automatically attacks, and it shows the slime’s hit animation with no life bar decrease being shown.

I will attach some screenshots that show the error.

Thank you for looking.

Unity 2.5D Turn-Based RPG: Build Your Own Turn-Based Battles & Environments

  1. Selecting and Attacking an enemy

This error means the index into the list of enemies is greater or smaller than the list size, eg. there is 1 enemy and you are trying to choose enemy at an index that is not 0. Lists, arrays, etc. are zero-based meaning if there is 1 enemy, the index is 0 and only 0 will be valid. If there are 2 enemies, only 0 and 1 will be valid. Share your BattleSystem code (the error happens in SelectEnemy) and we could take a look

1 Like