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"

Why won't the For Each Loop work inside my Function Library

So, I've been having a problem using built-in macros (e.g. For-Each loops, Compare Int, etc.) in function libraries. When I was running 4.5, this (some selection sort code): alt text

wouldn't compile because of the For-Each loop, the For loop, and the CompareInt functions*. I have since updated to 4.7, and now the only problem is in the For-Each. The error it gives me is this: alt text

When I have it jump to the error node, this is what comes up: alt text

Every part of the macro involving arrays (including the "inputs" section) gives the same error. What's the problem and how do I fix it?

*Interestingly enough, even when I was running 4.5, I had another function library in which I used the CompareInt function, and it worked fine in that one. I have no idea why it would work in one but not another.

Also, as a side note, does anyone know if they have added support for using time based events in function blueprints yet or if it's still confined to the level blueprint? Because that'd be useful.

edit: The variable I'm connecting to the For-Each loop is a structure. That shouldn't matter, though, should it?

Product Version: Not Selected
Tags:
for each 2.png (318.3 kB)
for each 1.png (351.0 kB)
for each 3.png (395.0 kB)
more ▼

asked Jan 14 '15 at 10:00 PM in Blueprint Scripting

avatar image

Kevin0814
31 4 5 6

avatar image Lukewade2 Jan 29 '17 at 11:43 PM

I have this issue too. Been scratching my head why it's not working properly, on a whim dragged all the logic out of the function and my code works perfectly. This has cost me hours!

avatar image mahlukat Aug 09 '17 at 08:11 PM

Hey Thank you Lukewade2!

I found this question when I search for my problem, I have a variable in struct, and I can see it exist when I look directly to the blueprint when I press f8, but my function cannot find that variable for each loop! Thank to you if I drag them all from the function and paste in event graph it works!

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

1 answer: sort voted first

They dont work because functions fire off as a single executed node, so certain functionality where it would need to do multiple executions just don't work, its why delays aren't supported in a function if Im remembering correctly. It will fire off the first loop body execution but not cycle through the rest. Maybe if you made a custom for each loop that will manually fire off the next index and you just loop the execution through it might work?

more ▼

answered Feb 23 '19 at 06:10 AM

avatar image

Grayve Rose
38 3 8 13

(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