I am currently creating a stun ability that allows the the player to stun enemies within a certain radius when they press “T.” For some reason, the game crashes when I use the ability. I tried cutting the for loop out, but that didn’t seem to do anything. I also broke the execution wire coming from the stun node. The game still crashed,
so I suspect the issue is with the stun function itself. Any advice is appreciated.
Not sure but i think “Last Index” should be Length -1 since its starting at 0. Otherwise you can try to store “Overlapping Actors” in a variable first. I had issues myself when using it directly, but that was a long time ago.
Regards
Yup, there is even a node called *LastIndex *- use it instead of *Length *to keep things clear. Or simply use ForEach loop with validation to be on the safe side.
I wouldn’t recommend putting the delay timer in the loop like that because it’s a REALLY bad practice.
Here’s how I’d probably do this: Get all the overlap actors and save them to an array=>run a for each loop to stun everything in the array(don’t use a regular for loop)=>when the stun loop is finished, start your delay timer and when it’s completed=>run a second loop that unstuns all of them=>clear the array.
I think I know what’s wrong.
The “Get Player Controller” node is not supposed to have a “World Context Object” pin if you’re calling it somewhere where you’re authorized to call it.
There are 2 things going on here:
- I think you have an option checked in the “Stun Target” parameter of your Stun function that causes the crash, this option is the “By reference” boolean that you can check when displaying a parameter’s settings, uncheck it. When you quickly create parameters by dragging a wire into the function, sometimes it creates them with this boolean checked.
- Remove the pin going in the “Get Player Controller” and restart your Editor
Tell me what’s up then.