In my co-op RPG-style game, I’m using a simple AI Move To node to get the enemies to move towards the players. While creating the game, I’ve hooked the Target Actor pin to the Get Player Character node. This works fine for creating the game, as it’s just me, but now that the game is nearing completion, I want the AI to move towards an array of players. Unfortunately I have no idea how to do this, and have been unable to find an answer. Details are below.
What I want: I want to get an array of players. I need to be able to remove/add a player to this array at will, because one class (assassin) can turn invisible (and removing him from the array will prevent him from being targeted). Once I have this array, I want to determine which player within the array has the least amount of HP (all players already have an HP float variable I can use). I want the AI to move towards that single player. If a different player becomes the one with the least HP, I want the AI to instantly switch and start targeting that player.
Question: How can I do this? It comes down to three basic parts: get an array of targetable players, calculate which player within the array has the least HP, and send that player to the AI Move To node. How can I do this?
Also, I assume I need to get the player array and subsequent code in the Gamemode blueprint? Versus the level blueprint?