Download

Help: Auto re-target enemy is working opposite O_o

Hey guys, im really hoping somebody can shed some light on whats happening. Im using the ‘mmokit’ and the retargeting system has always been questionable where it would work most of the time but randomly not work too. I have it all working now but there is this part of the code that is completely stumping me! So in order to track down the issue i was having where eventually the retargeting stopped working altogether, i ended up placing strings around in the code (im still VERY much new to BP’s) so to help me diagnose where the issue was.

Here is where i started: Below is the image of where i first placed a print string right after ‘True’ and just before 'Auto Switch Attack Target. The result was it was indeed printing the string so i knew it was making it atleast that far. This segment of code is called every time an enemy death notifies. Continuing on.


So then i went into the function 'Auto Switch Attack Target. This string successfully fired off in game as well so i know when im battling an AI its still successfully making it this far in the retarget system. From here i double clicked on the ‘Get Closest Enemy’ from the below image.


Now here in the below image is the Get Closest Enemy function. Part 1 (image below) fired off correctly. I even enabled the trace debug to see it ingame live and it works as intended. The print string did successfully fire off so it still gets this far (even confirmed the trace working)

Now right here in below image is part 2 of the same function, just continued on from the trace. I confirmed here with 2 strings that everything works. For every enemy that was around me and the enemy was Hostile (aggressive and attacking me), the print string fired off after every kill successfully. once the trace was ‘Complete’ it would also fire off the complete string right there at the bottom, so yet again i confirmed its still getting atleast that far. Now we move on to part 3 which is where the issue at hand is.


Here below is part 3 of the same function. This is where the issue lies. From here its getting that array of the traced enemies it stored and then loops the same number of times for however many enemies are stored in the array. Once that info is loaded up then for each loop it branches off to True/False. If the condition of get distance between Enemy and Self (playercontroller) (so lets say the enemy is right in front of me so its for example 100 distance) is less than the Min Distance, return True so branch off to True. If it came up False, Print that string and end. Problem is, its telling me the result is false every time even when enemies are directly in front of me while hostile.
Now i still got this working where i swapped the 2 green pins to opposite sides (so min distance green to green on top and get distance return value on bottom) and then it actually retargets but not accurately (doesnt choose nearest, just chooses random ones that are hostile that are around you). It unfortunately does on occasion targets a non hostile enemy which i have no idea whats up there but i chalked it up to its because the code doesnt make sense.

Im trying to make sense of why determine closest enemy code isnt working as its supposed to. Anybody able to shed some light on it? So to recap, basically its coming up false when it checks if distance from Ai to player is less than 3000 even when the 3+ hostile enemies are fighting me and directly in front of me.

Question #2: Whats it doing when it gets the condition result and comes up true then sets output to array element? Is it setting ‘True’ to each enemy in the array or is it setting the meters from player to each enemy in the array?