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"

ForLoop not firing correctly

So I am using a box collision component inside a blueprint to get all overlapping actors when this rail gun is fired, then running a ForLoop (or ForEachLoop, neither is currently working) on all overlapping actors to spawn an explosion and deal damage. But, while the get overlapping actors node is returning all the overlapping actors (12 here) using that result in either a ForLoop or ForEachLoop is only firing 6 times. As you can see in the blueprint, I'm getting the length of the array and printing that result, 12, the first number printed in the screenshot, then immediately plugging that value into a ForLoop and printing the index each time it fires, which is 6 times.

Does anyone know what the heck is going on here? Am I missing something obvious?

Manually entering 12 in the ForLoop makes it work on all 12 guys, so I have no idea why plugging in the length wouldn't work.

alt text

alt text

Product Version: UE 4.10
Tags:
forloop_01.png (509.4 kB)
forloop_02.png (236.6 kB)
more ▼

asked Jan 12 '16 at 09:16 AM in Blueprint Scripting

avatar image

Joe1029
83 11 14 19

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Looks like I just fixed the problem by making an actor array variable and saving the overlapping actors to that, then using that variable in the ForEachLoop. Still doesn't make sense though why I can't use the direct result of the get all overlapping actors node.

more ▼

answered Jan 12 '16 at 09:25 AM

avatar image

Joe1029
83 11 14 19

avatar image jayice Jan 12 '16 at 09:33 AM

The only thing that stands out to me is that you are using a class filter on the get overlapping actors. If all the actors are not of that class, then those that are not of class Zombie1Character, will not be returned.

Beyond that, can't really see anything wrong, as there is not much going on in the blueprint.

Jay

IceWare

avatar image Joe1029 Jan 12 '16 at 09:36 AM

All the actors are the same and of that class, plus the overlapping actors node is already returning the correct number so it is reading them all.

avatar image jayice Jan 12 '16 at 09:43 AM

It would be interesting to see if you get 7, or still the same 6, if you change the start index for the For Loop to 0 (zero). It would also be nice to see what the name of objects are that are being returned, or if there are null entries in the array. As well as the output log for a run of this.

avatar image Joe1029 Jan 12 '16 at 10:05 AM

Just tested that.Changing start index to 0 gets 7 results, 0-6. Printing the Array Element from the ForEachLoop when that is firing returns AI_Zombie_Character for every entry. Zombie1Character is the parent class for that actor.

avatar image jayice Jan 12 '16 at 10:09 AM

Joe,

Did you happen to check the output log, to see if there were any messages being displayed from the runtime of the virtual machine for blueprints? That might give the information your looking for. Although that would be more usefully done with the for each loop.

Null entries in arrays, will at times give blueprints, erratic behavior.

(comments are locked)
10|2000 characters needed characters left
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