Issue with spawning enemies using Actor Array
Hi! In my current project, when the one enemy dies, he is supposed to spawn at a location determined by a specific actor class spread around the map. There are ten of these spawn points, and he pics one at random before he dies and gets respawned there. My problem is, occasionally I won't run into him again throughout the whole test, and when I exit I get the attached error. Since this doesn't always happen, I'm assuming it has to do with one of the spawn points not working maybe? But I'm not really sure at all. I'd also like to know if there's maybe any way to attempt spawning him again if it fails, as that might still throw errors, but keep the game moving. Either way. I'd love any and all help with this. Thanks!
asked Nov 16 '15 at 04:05 AM in Blueprint Scripting
Length return size of array not max index. Length returns number of elements in array (if it's 0 then it's empty), because of that max index is Length-1 as there index 0, so you need to substracr Length by 1. Without substration sometimes your random node returns array Length which is too big by1 then the highest index in array, thats why you sometimes getting "Accessed None" error.
For future, "Accessed None" means you trying to access object that does not exist or object varable that is not set yet, in your case non existant array element.
Follow this question
Once you sign in you will be able to subscribe for any updates here