Theoretically you’d start here and there are better ways I’m sure
Start off clearing an array of enemy’s in range now make the array by getting for each overall and adding it to enemy’s in range array.
When complete. You want to get the length of the array and do a while loop on the array till its empty. In the whole array your getting zero and removing it from the array, and store it’s reference as say “checking ai” go into a for each loop on the remaining in range player getting their length and bool is it < then. If true set a bool to true. when it’s complete you then can say if it’s true then it’s the highest, add it to affectedAi array ( this is another array you’d want to clear when you first clear in range so it’s empty) if it’s false add it back to the players in range.
This will then go back to the while loop since in range is not empty… And grab next index zero and check again.
This will loop till there is no players left in the Inrange array which will then complete the whole loop.
Then on that complete you finally Foreach launch characters of the affectedai array.
I use this to sort players score in my game and have an example of the blueprint.
It’s been three days, sorry but I was quite busy. Tonight I tried to disable the collisions between the enemies and I found something interesting.
First of all, the last time I didn’t show the new blueprint.
This one is the AI: the only difference now is the new goal set when Stordito variable is found as false (so, if enemies are not stunned, their goal is the player as normal).
This one is the skill bp itself. For each enemy in the sphere, Stordito is set to True, then the Goal for the IA is set as the place of the enemy himself (so he stays in place), then his collisions are disabled.
Now, this is the video: v=oRUa5JLjXRM
As you can see, the first shockwave launches away the nearest enemies (note: these are the ones that have reached their IA goal, so they are standing still), but the other enemies are attracted to the player (these ones instead have not reached the player yet, so they’re actually still moving, though they’re resting in place because of the collisions with the other pawns). I think that the attraction is caused by the fact that they are still moving, like if the “XY override” of the launch doesn’t work. In fact, since the second shockwave all enemies are correctly launched away, because of the absence of collisions: no one is blocked from the other pawns, so he can correctly reach his target.
The point is… why this happens? How can i stop the enemies when the skill is activated? I’ve just tried to set the enemies’ velocity to 0 but didn’t work.
The new goal for the AI is set before the launch, but does not work anyway. As I said, I also tried to manually set the velocity of the enemies to 0 but it has been useless.
Not sure you can set thier velocity to zero. You need them to stop trying to trying to get to the goal. So when effected they just stop walking. Think of it this way if you set them to zero velocity it lasts a frame and then they start again which is quicker then blink of an eye.
So they need to stop persuit on either till they land or delay a second. I’m guessing anyway I could take a look at the project. I think we have the launch right it’s a matter of getting the ai to stop moving when it’s activated.
Could the movment be gated based on is walking? So they don’t move if in air?
I found the “stop movement” node, that nullifies the AI move to before the launch. At the end of the loop body, I’ve put another loop that resets the collisions of every enemy in game, after a little delay that avoids every possible problem until every enemy has landed on the ground.
With this set up the “AI goal” variable is now useless so I don’t need it anymore.