Destroy() Command Causing Crash under Odd Conditions

In this game I am adding enemies who shoot globs of poison, and they are working well, however an odd bug has arisen with the way I handle removal of enemies using the destroy command.

To get this bug to occur here are the conditions.

  1. A glob of poison must be on the ground.
  2. You must kill every enemy who can shoot the globs of poison.
  3. When the timer runs out for poison being on the ground, the game will crash, assumedly due to the enemy.die() method I added which is basically just a weird way to call the enemy.destroy() method to get rid of it. However no other enemy in the game has caused this sort of bug.

*Additionally, if there are 3 globs of poison on the ground, and the poison spitting enemy is dead, only the final glob of poison to be removed will crash the game.

Controls: WASD: Movement___E: Inventory___L-CLICK: Equip Item / Use Item

idle.html (65.8 KB)

What’s the error message and trace?

I have no idea, I’m coding this in visual studio without error codes or traces. The thing just stops moving and I try to track down bugs manually.

Run it in the browser and expand the error message in the console.

HAHA, I have coded 1200 lines without realizing there is an error console in the inspect element part of the browser. I found the error, It was deleting the entity before completing some of the update steps. Thank you, have a great day