x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

alt text

Product Version: UE 4.9
Tags:
clipboard01.jpg (516.8 kB)
more ▼

asked Nov 16 '15 at 04:05 AM in Blueprint Scripting

avatar image

Ghodan
19 6 6 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Nov 16 '15 at 05:05 AM

avatar image

Shadowriver
37.3k 936 172 1116

avatar image Ghodan Nov 16 '15 at 07:20 AM

Thank you so much! That seems to have fixed it.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question