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"

ForEach Loop losing data in array

I have an issue where when I try to use a for each loop, the information in the array I call the loop on, disappears. I have checked that the data is in the array. See GIF for example. (The values turn to null as soon as it's accessed) alt text

I have also posted a picture of how I add values to the array. It just an event that I call from another BP. alt text

Any Suggestions? I'm still kinda new to unreal, but I don't fully know why this is happening. I had also tried using sets, and that also didn't work.

Thank you for any and all help.

Product Version: UE 4.19
helpfourm2.png (66.6 kB)
more ▼

asked Aug 23 '18 at 12:16 AM in Blueprint Scripting

avatar image

1 1 3

avatar image Nebula Games Inc Aug 23 '18 at 03:01 AM

Does the second print string ever fire? Also what is before all of this in the flow of execution?

avatar image TheRegalCasey Aug 23 '18 at 02:19 PM

The Second string never fires, before this is just a lot of code to get an actor that is the attach parent's parent.I will post more details.

avatar image Tuerer Aug 23 '18 at 06:56 AM

Your screenshots are not informative enough. All I can see is the ForEach Loop prints your string N times depending on the array length. What happens to the array elements is unclear.
Why do you think something gets lost? What happens to the array elements - maybe there are some further conditions in the execution sequence?
If you could provide more detailed screenshots that would be helpful.

avatar image TheRegalCasey Aug 23 '18 at 02:23 PM

See that's just it, the array never gets printed. It only prints the first string, but not the second. I don't understand why the references get lost, seeing I don't clear them anywhere.

avatar image Nebula Games Inc Aug 23 '18 at 02:31 PM

You must be clearing the array somehow. Does the completed pin fire? Sometimes blueprint nodes are just "bad" deleting the non-working ones and replacing them sometimes fixes problems that have no other explanation. Also try printing a string for the array length just prior to the loop and see if it has anything in it.

avatar image TheRegalCasey Aug 23 '18 at 03:06 PM

So I just tested printing the string length. If you look at the Top of the 1st new screenshot. I added a print string before the branch (After posting the screenshot). And it prints the length. But if it's after the branch, it prints 0.

avatar image TheRegalCasey Aug 23 '18 at 02:52 PM

Added some additional Screenshots. Warning, it is a mess. alt text alt text This is a majority of the BP. But I'm just trying to figure out why the "for each" isn't running

avatar image Tuerer Aug 23 '18 at 03:00 PM

1st screenshot, bottom center. Shouldn't that ADD node be hooked up to AttachToActor?

avatar image Nebula Games Inc Aug 23 '18 at 03:03 PM

Umm.....I just took a couple minutes to try and figure out that appropriately named "mess" of blueprint you have there and I am sorry I have no clue what you are trying to do. But after looking at this, I can tell you with 100% certainty the least of your issues is why the "For Each Loop" isn't firing. You are running a million things off tick....one of which is the "For Each Loop", I can't think of any situation (maybe there is 1 out there but I doubt this is it) where you would want a "For Each Loop" to run on tick, that is pretty absurd. You have kind of mitigated that effect somewhat by using a ton of "Do Once" nodes with resets all over the place that I can't really follow.You also have a bunch of booleans regulating flow through this massive thing here but I can only see where one of those booleans is being "set" which makes it even harder to follow exactly what you are trying to accomplish. My advice, write down, step by step the "GOAL/MECHANIC" desired at the end of all of this and we will work on re-doing this entire set-up because I don't think this is something you should event attempt to salvage in its current state.

avatar image TheRegalCasey Aug 23 '18 at 03:16 PM

Thank you, I'm sorry that you had to try to read it. I'm trying to emulate a motor, and this is just a wire end. I'm still super new to unreal programming, but thank you for helping me. I did just solve it, it was a simple checkbox in the setting of the variable.

avatar image Nebula Games Inc Aug 23 '18 at 03:20 PM

I mean I am glad you fixed it, BUT I caution you, that set-up is bound to give you problems down the line. In general "tick + loop" is never a good idea. I would switch this over to "events, timers, functions etc". Tick is a heavy node to use for something like this and probably only needs to be used for smooth motion where you really do need to update the location of an object every frame.

avatar image TheRegalCasey Aug 23 '18 at 03:35 PM

Thank you, Events are a place that I struggle with, so I will take your advice on my next project. I would try to change things if I didn't have a week left on this 3-month project. Thank you again!

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

1 answer: sort voted first

Solved... In the setting of the array, I needed to set "Instance Editable" to be true. Sigh... Thank you all for your help.

more ▼

answered Aug 23 '18 at 03:13 PM

avatar image

1 1 3

(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