0
\$\begingroup\$

I am working on a tile based game. I have a board generator and on the hard level I have to create 900 game tiles and add them to the screen. This takes about 3 to 4 seconds to complete. I started moving the UI code to C++ but ran into tons of issues and read that UI in C++ isn't recommended as its bug prone and difficult to work with. So I moved it back to blueprints and to avoid hogging all the CPU for 3 to 4 seconds I implemented a system to layout the board one row at a time with a short delay between to free up the CPU. This works beautifully and the board is laid out one row at a time and with the delay the FPS still hangs around 50 while doing it so sweet.

But I am running into a problem with the delay nodes. I layout a row, delay for a short period and layout the next row and so on. The proplem is as soon as I hit the first delay node, execution picks up AFTER the event containing the delays finishes.

1. While debugging, this breakpoint is the first one hit as expected.
2. Execution then enters the Layout10x10EasyBoard event as it should where a delay is triggered between rows.
3. Before the delay is finished execution picks up here and continues down the line before the delay even finishes.
4. Then this breakpoint is hit and we continue showing the rest of the game tiles.

enter image description here enter image description here

It's my understanding that execution will stop at a delay so what I think should happen is the Layout10x10EasyBoard should finish execution before picking up at number 3. But that is not happening. The code at the end of the line requires all the tiles to be created before continuing and since the delay seems to have no effect on execution, that code is not working correctly. Does anyone know why the delay is not stopping execution?

\$\endgroup\$
  • \$\begingroup\$ I changed the delay time to 2 seconds, and one row is laid out every 2 seconds as expected however the execution is still the same, the first delay is hit, then execution goes immediately to #3 before the delay is finished. Then after 2 seconds execution goes back to #4. \$\endgroup\$ – Jason Crosby Dec 18 '17 at 15:57
  • \$\begingroup\$ Are you causing the "10x10Easy" entry point more than once? Delays are ignored if you encounter the same delay from the same entry pin (essentially) while already delaying. They don't actually "pause" execution, they just schedule it for later. \$\endgroup\$ – user1430 Dec 18 '17 at 17:14
  • \$\begingroup\$ No I'm only calling it once but I was able to figure out this is actually expected behavior for delay nodes. \$\endgroup\$ – Jason Crosby Dec 18 '17 at 17:25
0
\$\begingroup\$

I also posted the question to UE answer hub and apparently this is how delays are supposed to work. I added an event delegate to call at the end of the tile creation process and now the code that needs to wait, wont run till all tiles are created.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.