Advertisement

Menu UI - Partial Pausing the Game

Started by August 06, 2018 11:07 PM
7 comments, last by Scouting Ninja 6 years, 1 month ago

Hello all!
 

Unreal Question: I am wanting to make a inventory screen that when opens, the camera zooms in to a close-up of the character, pauses the enemies and environment, but keeps the character's idle animation. The player would be able to equip items and see them appear on the character in real time. However, I don't want an enemy running up and killing the player or an environmental hazard killing them. If something like that is possible, how would one achieve that? 

Here is a similar look of what I want to accomplish (I'm assuming this is a MMO so the game isn't actually paused, but this is similar to the look I want)

Image result for inventory UI with character

 

However, I could settle for something like Destiny's menu, where the character model appears in the menu and not a camera change, but changes are reflected when items are equipped:

Image result for inventory UI with character

 

Let me know if I can better clarify anything, and thanks in advanced!

You could pause the game and make the character tick when paused. Not sure it'd still react to input, so you may want to disable it on the controller too.

Advertisement

Don't pause the world.   

In general a pause system stops all animations. It will stop no matter if the characters are idle, or if a character is running, crawling, swinging a sword, jumping through the air, blocking a blow, or doing anything else.  In that scenario you can't continue to play animations, not even idle animations, because they could interfere with other things that are going on. You can't have two characters locked in a battle to the death frozen in time while another is breathing and idling while changing outfits.  All animations must stop in that situation, or the flow can't interrupt gameplay.

If your inventory screen is outside the main gameplay environment there is no need to pause the world.  The character is still visible and animations are running, the difference is that the character isn't being controlled directly by the player.  Do all your menus and UI stuff, and have a character in a world that responds to events coming from the UI.  You might have the UI trigger animations to show weapon swings when a different weapon is equipped or other animations, but it is the menus controlling the character, not the human.

 

Well, I guess "pause" should indeed be reserved for... well, actually pausing the game. Sorry about that naive answer ;)

An alternative would be lowering "Global Time Dilation" and increasing "Custom Time Dilation" on the character - it wouldn't exactly pause everything, but the achieved effect would be similar. Another, which may be the preferred way I believe, is having some variable in your Game State which all relevant entities use to know whether the menu is active or not and act accordingly.

Regarding the varied scenarios where "playing an idle would break the flow", you could make it work with a more complex system.

For instance, you could check if the game is paused and, should that be the case, decide whether to simply fallback to an idle state (say if the char wasn't in combat) or just freeze it in place (setting playback speed to 0) and layer an idle on top of the current one, eg. keep the sword raised, but the character still breathes (and maybe looks around as if thinking "what the heck is happening?" if you're going for this vibe).

Sorry for the delay in responding. Been a busy week, but thank you guys for responding so quickly. Just a few follow ups:

On 8/6/2018 at 11:17 PM, frob said:

Don't pause the world.   

In general a pause system stops all animations. It will stop no matter if the characters are idle, or if a character is running, crawling, swinging a sword, jumping through the air, blocking a blow, or doing anything else.  In that scenario you can't continue to play animations, not even idle animations, because they could interfere with other things that are going on. You can't have two characters locked in a battle to the death frozen in time while another is breathing and idling while changing outfits.  All animations must stop in that situation, or the flow can't interrupt gameplay.

If your inventory screen is outside the main gameplay environment there is no need to pause the world.  The character is still visible and animations are running, the difference is that the character isn't being controlled directly by the player.  Do all your menus and UI stuff, and have a character in a world that responds to events coming from the UI.  You might have the UI trigger animations to show weapon swings when a different weapon is equipped or other animations, but it is the menus controlling the character, not the human.

 

So if I were to have a blueprint or code in Unreal that when I press "escape" to bring up the menu it sets the game to pause, that cancels any animation in effect? I've mostly just been using Unreal's base animations as a stop-gap for the time being, but I haven't noticed that happening. It makes sense that if my character was mid-swing when I paused and a camera zoomed in on him, it would be paused mid animation and wouldn't revert to idle for a menu.

For the second paragraph you're talking about only allowing the inventory screen when the character is in a safe place? (Which I think I'm leaning towards having a designated area for equipping new items) Or creating a separate, but identical character that is displayed only in the UI, and idles, but animates when items are equipped? How would the new items equipped translate to the "in game" character? Perhaps I'm overthinking it or misunderstanding something.

On 8/7/2018 at 2:26 AM, vlucki said:

Well, I guess "pause" should indeed be reserved for... well, actually pausing the game. Sorry about that naive answer ;)

An alternative would be lowering "Global Time Dilation" and increasing "Custom Time Dilation" on the character - it wouldn't exactly pause everything, but the achieved effect would be similar. Another, which may be the preferred way I believe, is having some variable in your Game State which all relevant entities use to know whether the menu is active or not and act accordingly.

Regarding the varied scenarios where "playing an idle would break the flow", you could make it work with a more complex system.

For instance, you could check if the game is paused and, should that be the case, decide whether to simply fallback to an idle state (say if the char wasn't in combat) or just freeze it in place (setting playback speed to 0) and layer an idle on top of the current one, eg. keep the sword raised, but the character still breathes (and maybe looks around as if thinking "what the heck is happening?" if you're going for this vibe).

Ok, that last one does sound a bit more complicated, but I think I understand what is involved in it. And it does seem closer to the current idea for the UI that I had.

 

4 hours ago, Brandon Segraves said:

So if I were to have a blueprint or code in Unreal that when I press "escape" to bring up the menu it sets the game to pause, that cancels any animation in

It sounds like you don't understand the game loop yet, so I will explain it here, once you understand the answer is very clear:

A game is just a loop when it is in code, usually a kind of while loop.


While (Quit == false){
  //The code for the game is here
  //Seting Quit to True will stop the loop
}

Often pausing the game is some kind of IF check to see if the game should run:


While (Quit == false){
  if (Pause == false)
  {
    //Game runs while pause is false
  }
  //if pause is true the game code is just skiped over
}

So you see if you pause the game you pause everything, as such you shouldn't use pause for these effects. Instead you should only pause some things, not all things.

In Unreal, we can not only pause the game but also pause every level that is active, because every level is a sub loop inside the loop:

GameLoop.jpg.6b27ea4bbc3c92d9abc709fa4698a840.jpg

The Unreal UI is also a sub loop, so is the character controller, neither of these are in the "Pause Game" check but instead is an actual level on it's own:

GameLoopSub.png.fc431c088219dcbe3b80ef5717a43275.png

As you can see if you call "Pause Game" from the UI the levels will be paused, but both the controller and the UI will keep functioning as normal.

If you wanted the character and world to pause, but you don't want the camera to pause, you would use two levels. Level 1 will have content to pause, level 2 will have whatever should not pause. Then In the UI or Controller you will tell it to pause level 1.

 

If you haven't used Unreal's level streaming system yet, this is how:

1.) Under the Window option in the editor, select "Levels".

2.) Create a empty map, completely empty.

3.) In the "Levels" window add the new map to the list of levels. This will immediately add the two levels together.

The reason you want a empty level is because lights etc will conflict when streamed into one scene. As a example I added a "default" level into a existing level:

Streaming.thumb.jpg.bda1dcf7618c04b1f88d0ff4f5c63dde.jpg

 

In theory what you want is: A persistent that is empty. Inside this will be the "World" level and "Don't Pause" level. Under the world level you will also have shards that you are streaming.

Don't be afraid of Unreal's level streaming, it is supper easy to use.

 

Advertisement

I'm still learning Unreal, so I don't know how to archive this in Unreal. I'm sorry in advance if this might not help!.

I think you could just makes all enemy stop updating its states, including animation and such. I guess you could disable most of the components inside the enemy object while keeping the player one active (well I guess you still have to disable some of the player actor's components).

Personally I think it might not wort headaches implementing the menu where player actor still active and the rest is not. I think switching to another screen/level/scene temporary (what is the word used in Unreal ?) will look better and more straightforward to implement. Imagine if the actor is middle of some action, and the player enter the menu, are you going to switch the animation to idle ? What about switching back to the old state after exit menu? Will it perform the same? etc. 

http://9tawan.net/en/

40 minutes ago, mr_tawan said:

Imagine if the actor is middle of some action, and the player enter the menu, are you going to switch the animation to idle ?

Actually when you use two levels this becomes very easy, because you would just use two of the player characters.

1.) One character will be in the world level, the other one in the DontPause level. The second one should be invisible.

2.) The moment the game is paused the original player model animation is captured as a Snapshot.

3.) The second character is turned visible and active, while the original is made invisible just before pause; or after pause using the Unreal "Tickable when paused" function.

4.) The second character Blends between the Snapshot animation and idle animation.

5.) Equip character etc. Blend back to the snapshot animation as the player exits menu.

6.) Update the original character with the new gear, make it visible and active. Hide the second character and making it inactive. Then unpause the level.

 

Taking a look at the Unreal tools, maybe the developers had this in mind from the start?

This topic is closed to new replies.

Advertisement