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"

ForEachLoop does not get all actors from class

Hi,

I have a blueprint system where upon the player overlapping a trigger volume the blueprint spawns AI from Class on the location of actors from another class (hidden in-game) that basically functions as location points. By connecting "Get all Actors of Class" with a ForEachLoop and connecting a GetActorLocation with the Array Element I spawn AI actors on those locations. But the problem is that it doesn't spawn actors on all of those locations. I have placed 7 location markers but on only 4 or 5 of those AI actors get spawned. If this doesn't make sense then here's a screenshot:

alt text

Is there anything I'm doing wrong here? I do get some errors in the Message Log but I'm not sure I understand them:

Error Accessed None 'CallFunc_SpawnAIFromClass_ReturnValue2' from node Spawn Default Controller in graph 'EventGraph' in blueprint Stream_Level_Test3

Error Accessed None 'CallFunc_SpawnAIFromClass_ReturnValue2' from node Spawn Default Controller in graph 'EventGraph' in blueprint Stream_Level_Test3

Error Accessed None 'CallFunc_SpawnAIFromClass_ReturnValue2' from node Spawn Default Controller in graph 'EventGraph' in blueprint Stream_Level_Test3

Is there something I should be doing different?

Product Version: UE 4.9
Tags:
spawnai.png (994.5 kB)
more ▼

asked Sep 20 '15 at 12:04 AM in Blueprint Scripting

avatar image

Cryptical
58 8 12 27

avatar image Arida Sep 20 '15 at 08:35 AM

Probably related to this bug: https://answers.unrealengine.com/questions/294580/get-all-actors-of-class-with-level-streaming-broke.html

Try adding a small delay before GetAllActorsOfClass.

avatar image Cryptical Sep 20 '15 at 05:04 PM

Hi Arida,

Thank you, I did not see that post. Unfortunately adding a delay does not solve the problem for me but I'll be sure to keep an eye on any future bug fix notes. For now I'll just use a transform or vector array. Thank you!

Edit: It does actually seem to get all locations. When I use a print text for each array element it does return 7 vector values. It just doesn't spawn AI on all those values. I may have to look into that.

Edit 2: connecting a get object name to the return value of "Spawn AIFrom Class" and using a print text confirms that it does not get all actors as it gives me 3 null messages. I'll just wait for any bug fixes.

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

3 answers: sort voted first

Alright, I think I found my answer and I feel kind of silly now. The problem wasn't that it didn't get all actors. It was simply that they were too big and caused collision fails. Checking "No Collision Fail" confirmed this. It simply didn't spawn actors on locations where the collisions would fail.

With that said, thank you for your help!

more ▼

answered Sep 20 '15 at 05:35 PM

avatar image

Cryptical
58 8 12 27

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

You may also want to take a look at the array being used, to see if there is a null value in it. before you start to access the data. The error you show, will may cause the loop to terminate prematurly, and not fully process the array. To check for a null, get the != node, wire up the the output of the array into the node,and then wire the != into a If node (branch). This will check for a null, and allow you to bypass it.

Hope this helps,

Jay

IceWare

more ▼

answered Sep 20 '15 at 10:42 AM

avatar image

jayice
1.4k 41 28 56

avatar image Cryptical Sep 20 '15 at 05:03 PM

Hi Jay,

Using a branch and checking for a null does indeed get rid of those errors, thank you. Unfortunately it does not solve the problem of not spawning actors on all of the locations.

With that said, I do appreciate not getting those errors anymore so thank you for this advice. I'll make sure to remember this for the future.

avatar image jayice Sep 20 '15 at 05:35 PM

one quick question, that "no collision checkbox"? could that be preventing the spawn at certain locations? Such that if there is collision, the spawn doesn't occur? The logic for the node option maybe inverted, but I couldn't find any information quickly for that node,and was just wondering. As I don't know the location, etc I mean if the level is flat, this is no issue of course, but if there are hills, or other objects at the spawn point?

Another thought, are you now checking after the spawn node, to see if the actor was truely spawned? So that some error checking code can be injected? to give some more information concerning the issue?

avatar image jayice Sep 21 '15 at 01:00 PM

Hi Cryptical!

Ok with the errors out of the way. There is another thing, that makes talking about this sort of stuff easier, or at least to me.

That is instead of the screen shots, when you have the function displayed in the UE4 editor, do a CTRL+A to select all the nodes in the blueprint function your looking at. Then do a CTRL+C, in order to copy it to the clipboard. Grab your favorite text editor, and do CTRL+V, in order to paste from the clipboard (or the equivalent for the OS of choice,and I'm not trying to be patronizing, just attempting to stop forum post tag!)

When you take a look at what was pasted in, you will see the entire "function" there in text format, GUID's for vars, init states, etc. This has helped me track down so many issues, some Epic's, mostly mine. Because it makes a lot of the error/warning messages meaningful. Now you know which node they are talking about! lol

Also, if you paste that back into the UE4 Editor, the Blueprint editor, understands it, and will create all the nodes, it doesn't really create the variables for you, so that's a gotcha, but you can see what the type of the variable is, etc. So it's still pretty fantastic. And yes, I have a product i'm building based solely off this. It can be used to do a very quick backup of blueprints, if your getting concerned about something. Although not the best way to do it, but it's fast. Best way in my opinion for a back is, to isolate all the development your doing, and then simply copy that directory to another directory, and you've got it all, and can be used to restore.

So why all this verbage, it's faster to see what is going on in your blueprint doing it in this fashion, for the function in question, than the screen shots. When I see the screen shots, i'm always like, what the hell is happening off to the right and left! lol

Jay

IceWare

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

Hey Cryptical,

Lol, I just posted that question back to ya! Glad it's working, and have a great day!

Jay

IceWare

more ▼

answered Sep 20 '15 at 05:37 PM

avatar image

jayice
1.4k 41 28 56

(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