I want to create a UI when the player clicks a button, and then the player performs some operations in the UI. When the player’s task is complete, the widget should be removed, and subsequent operations should be executed. The issue is that my subsequent operation will switch to another task, but I don’t want this to happen immediately. I want to pause the game when the UI is created. However, when I create the UI, the pause game node becomes ineffective, but it works fine when I don’t create the widget. Is there any way to fix this?
So, you create widget. Delay for 30 seconds , set input mode to UI only and then pause the game.
Delay does not work.
Create print string after delay (set it to 5 seconds) and see if text appears 5 seconds after you create that widget.
On widget construction set " game paused" it’s a node you can call
Update: derp I see you have it already…is in on construct? Try placing it first before other functionality
Maybe putting it at the front is a solution, I haven’t tried it, but the main issue is with the underlying task system I wrote. After this widget is created, there will be some operations that switch to another task. If I move it to the front, the task system might encounter problems, so I used the ‘pause game’ to let the player complete the task in the UI first, and then the UI will let the game continue to run in order to proceed with the subsequent logic here. But the pause isn’t working.
If the game is paused, player can not complete tasks in the UI because the game is paused. Maybe you can make widget react to input or clicking a button, but even then you need to un - pause the game for something to be executed (in the widget or anywhere).
void UMainTuoDong::JiaZhi(int i)
{
zhi += 1;
if (zhi == 2)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, “111”);
UGameplayStatics::SetGamePaused(GetWorld(), false);
}
}
Actually, that’s what I did. The widget has an option to enable the game, and I thought that only UI mode would allow the player to interact without affecting the logic inside the UI. Then, I followed it up with a pause game command to ensure that all the game logic after that point would be paused. Afterward, the player only needs to operate within the UI, and I check for the value being 2 within the UI, rather than in other objects. When the value equals 2, I set SetGamePaused to false, and the game logic continues. However, just like the print statement above, the subsequent operation is almost executed instantly, even when SetGamePaused is true. Even using a delay doesn’t work—it cannot stop the process.
There is a “is_game_paused” check.