Announcement

Collapse
No announcement yet.

How to store pin values when using asynchronous nodes?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to store pin values when using asynchronous nodes?

    tl;dr: I'm trying to download all of Twitch's emotes from their server. I go through a list of names and IDs, use the asynchronous "Download Image" node, then put the downloaded texture in a Map with the emote name as a key. But by the time all the emotes have downloaded, the "name" string has advanced to the last one in the list, so it ends up as the only key in the map.

    Here's my BP: https://i.imgur.com/VotVkKz.png

    "Load Twitch Emotes" just grabs the json from here and returns two arrays, Names and IDs. (No, I can't use a map here. Because UE4 and commas)

    I loop through the array of names, each time getting the ID (the element in IDs with the same index). I pass those into a function which builds the URL, calls Download Image, and adds the name and texture to the "All Twitch Emotes" map. The "Print String" node, for each emote, ends up printing out "TeamFearTWD" (the name of the last emote in the list, also why the hell did they add two emotes for that show, the writing has been garbage since the farm)

    I see what's happening here: Download Image is asynchronous, so once any emotes have been downloaded from the server, the loop has already completed and "Name" is the last one in the list. The "Add" node takes the string input and follows it all the way back to the output of ForEach, which is now"TeamFearTWD". What do I do about this? I thought passing it into another event would help, but no. I tried copying the String each time in the loop - that's that weird icon on top, if like me you've never used it - and somehow that also doesn't work. I even tried Appending an empty string to the string, but it still doesn't work (or it gets compiled out).

    How do I actually store the value of a BP pin, so it's available after an async node returns?
Working...
X