Hi deflif007, I replied to your question by e-mail yesterday and said I would reply in more detail on the forums when I had the time. I wrote a post earlier to day, but for some reason it doesn’t seem to have been posted. Thanks for stepping in again, ! Great solutions as always. I’ll write a new post where I take 's suggestions into account.
Making a receive heal event in Unit_Parent is probably the way I would have done it myself. This is pretty flexible since you can easily add things like healing powers from other units etc. now that you have a dedicated event. You might not need to run it through the game mode, though. Something simple like this does the trick:
Here’s a quick .gif of it in action.
For this to work, you need to make sure that you have collision enabled properly, though. I would enable collision of the skeletal mesh of all units, set their object type to WorldDynamic and enable generate overlap events. Then set both the WorldDynamic collision of the skeletal mesh and your powerup to overlap. The default units don’t have collision enabled for performance reasons, but the impact is minimal unless you have vast amounts of units.
For AI units dropping powerups you could again do something like suggested. You can again make it slightly simpler if you know that units will never be between tiles when they die (which never happens in the default toolkit), in which case you can simply spawn the powerup at the current location of the actor without running it through Index To Vector. It’s also generally advicable to get an index from the Vector Field Array instead of using the “Index to Vector” functions, as it is agnostic to the grid type.
As has mentioned and I mentioned in my e-mail, your third question is the trickiest bit by far. If you have a situation where you have complex terrain and multiple player to escape from you will need to know all possible paths for the next turn for all player units so that the AI can avoid them. This is not trivial to solve; especially if you want to avoid any drop in framerate. What I would probably do is to create a modified version of the Pathfinding function that initially adds the location of all player pawns within a reasonable distance of the AI to the open list. This way you would have a pathfinding that simultaneously spreads out from all candidate player units. You would run this for a fairly large move range (I think the movement range of the AI unit plus the movement cost between the AI and the closest player unit should be sufficient).
You would need this function to write to a different aray than CanMoveToArray so the two can be compared. The new array would function sort of like a threat map. You would then look at all locations that the AI can reach in one move from the CanMoveToArray and compare it to your new ThreatMap array. The AI should choose to move to the tile with the highest cost in the ThreatMap, as this would be the tile within the AI’s reach that takes the longest for all player units to reach. That’s the best solution I can think of currently. Like I said it’s a pretty tricky thing to do, and there might be much easier ways to fake it if you need a less generic solution for a few specific scenarios.
edit: The green ball is a float output. You can add it to the custom event in the details tab like so:
The second ball is a reroute node. You can place it by dragging out a float from an output and letting go anywhere in the graph editor. A dropdown appears where you can select “Add reroute node”. The third is a simple float / float node.