Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

You mentioned that you're not a good programmer, so here's what the code could look like:

  1. Determine the enemies in range.
  2. Sort enemies into lists (arrays) based on priority (regular enemies or boss enemy).
  3. Attack boss enemy if there are no regular enemies.
  4. Otherwise check which enemy is closest to the exit (check y pos with y pos exits). Then target the enemy closest to the exit.

Note that this only works if the exits are all at the same y position.  Otherwise split the list of regular enemies into a list per exit (check if the x pos is equal to the x pos of the exit (probably use a small threshold)). Then check foreach list which enemy is closest to its exit.

I completely agree. We'll adjust the aiming system as it's still not working as intended, and this issue with the boss just makes it worse indeed. We have a similar system as you have mentioned (except in jam spaghetti code), so when we refactor it properly we'll tackle this issue too. Thank you for taking the time to break down a good direction to solve it!