9 ms·
Game devs explain the tricks involved with letting you pause a game
- bitwize 7mo agoFor my game (custom engine) I had a way to stop the game clock from advancing, while the input and draw loop kept running. It would also put the game into the "pause" input state during which only the resume button would be active.
- DeathArrow 7mo agoNot sure if slowing down time is the right approach. The best approach would be using something like if(game_is_paused) return; in the game loops.
- astrobe_ 7mo agoIt depends on how your timers are implemented. If they are implemented as a "rendez-vous" absolute date (as in UTC for instance - not in local time unless you want to add "eastern eggs" related to daylight saving time...), this will cause bugs. If you implement your own in-game monotonic clock that you can stop, it should be ok.
- sweetjuly 7mo ago>If they are implemented as a "rendez-vous" absolute date Do people actually do that? What's the plan for when the user sleeps their machine? All the events just inexplicably happen all at once when they wake it?
- stoltzmann 7mo agoI've implemented timers that had timeouts using unix timestamps, but only for multiplayer - when a player's attempt to connect to the server times out, etc. Inside the game loop, we would keep the global tick counter that incremented on every tick, and timeouts would be based on that rather than on UTC. The tick counter was updated only when the game logic was actually running. Our approach to pausing was to not run the functions that handled frame updates or physics updates, and to only run the rendering functions. Generally we would never care about actual world time other than for some timeouts like for network (as the time passes for everyone), or for easter eggs like changing the tree models for Christmas or so. I don't think anyone serious would implement event timers based on real time.
- astrobe_ 7mo agoThat's sort of the point TFA. You make implementation choices that feel OK and then the time comes to implement the "trivial" pause function... In other domains, adding the delta time of your main loop to your timers can cause (logical) clock drifts in the long term because of resolution errors.
- kdheiwns 7mo agoGames are multithreaded and have loads of objects running everywhere. If you're using anything that's not a custom game engine, there really isn't a single main() function that you can plop an if statement like that into. Slowing down time applies it universally. Otherwise you're going to need that condition to every single object in the game.
- danhau 7mo agoThe slowing down thing sounds like a hack needed for engines that don’t give you control over the main loop. I haven’t tried this yet, but for a custom engine I would introduce a second delta time that is set to 0 in the paused state. Multiplying with the paused-dt „bakes in“ the pause without having to sprinkle ifs everywhere. Multiplying with the conventional dt makes the thing happen even when paused (debug camera, UI animations).
- kdheiwns 7mo agoUnity does this. You get scaledDeltaTime (when you set game speed to 0, it'll return 0) and unscaledDeltaTime (returns time between frames ignoring game speed). Pauseable logic uses the former. Pause menus use the latter.
- torginus 7mo agoI don't think it's a hack necessarily - as a well implemented time system would produce the same results at game rate = 0 as with pause. Also there's a need for different time domains - like imagine, in a paused state the menu animations still need to play, or if the player enters a conversation, the game logic needs to pasue (depending on designer intent etc.)
- flohofwoe 7mo agoIt's usually not as simple as that. You'd still want to at least keep the UI alive, and you also need to continue rendering while the game is paused because the swapchain surfaces might lose their content (window resizing, changing the display mode, alt-tabbing to the desktop etc). E.g. when you open the ingame menu, the inventory (etc) you usually want to pause the gameplay, but still want to interact with the UI. Sometimes that means that at least also some of the gameplay logic needs to remain alive (inventory management, crafting, levelling up, etc...). There are also a lot of games which need some sort of 'active pause', e.g. the gameplay needs to stop while the user can issue commands to units (traditional example: real-time combat with pause like in Baldurs-Gate-style RPGs). Sometimes the underlying engine also doesn't properly separate gameplay logic from rendering, e.g. you can't skip one without also skipping the other (which is an engine design bug, but similar situations may also happen up in gameplay code). Finally: pausing and the save-game-implementation is often an afterthought, but really should be implemented as the very first thing. It's quite easy to run into the trap that a frame also needs to advance time. If the game has the concept of a fixed-duration 'game logic tick' which is independent from the frame rate you're already halfway there though, but many games simply use a variable-length game tick which is identical with the frame duration.
- qwery 7mo agoYep, this comment does a good job of illustrating the (surprising) complexity of this. I'll add that the notion of the "time scale" variable as mentioned in the article is something that's only solidified/codified since Unity and the like came about. And at the same time, the way Unity et al. works[0] doesn't really encourage thinking about what I'd call "main loop logic" in the bottom-up way that's required to build a really robust system for managing states. You can do it, of course, (you can write as much code as you want) but by default, everything in the scene is "active" and somewhat independent from everything else, and you don't have direct control over the various major systems. [0] I guess I should say "worked" -- I mostly used 3.x and a little bit of early version 4 -- I'm sure it's improved but I wouldn't expect anything drastically different.
- daemin 7mo agoA surprising number of systems break down if you pause time by passing a 0 time delta, hence why slowing down time is usually the thing that gets done. The alternative (which you imply with your suggestion) is to pass the many paused states down to every system which further complicates their implementation and is a major source of bugs. The added fact is that many systems still need to continue running, such as audio, video, and input otherwise the program doesn't appear to respond to input and so isn't in a useable state any more.
- vintermann 7mo agoOne of the things that impressed me in Quake (the first one) was the demo recording system. The system was deterministic enough that it could record your inputs/the game state and just play them back to get a gameplay video. Especially given that Quake had state of the art graphics at the time, and video playback on computers otherwise was a low-res, resource intensive affair at the time, it was way cool. It always surprised me how few games had that feature - though a few important ones, like StarCraft, did - and it only became rarer over the years.
- dSebastien 7mo agoI wish I kept my demo files!
- applfanboysbgon 7mo agoChecking in as a random indie developer who still prioritises determinism in my engine. I don't understand why so many games/engines sacrifice it when it has so much utility.
- bob1029 7mo agoDeterminism isn't essential to achieve record/playback experiences. You could just record the transform of the player at some fixed interval and then replay it with interpolation. This is arguably more "deterministic" in a strategic sense of shipping a viable product.
- magicalhippo 7mo agoThe player is just one entity, you'd need to do the same to any other non-trivial entity. And you couldn't use fixed intervals and naive interpolation, otherwise you'd have entities clipping the ground when bouncing etc.
- JoshTriplett 7mo agoI think if it were as simple as "remember the RNG seed", game developers would do it every time. But determinism also means, for instance, running the physics engine at a deterministic timestep regardless of the frame rate, to avoid differences in accumulated error or collision detection. And that's something that needs designing in from day one. Thank you for still prioritizing it.
- bel8 7mo agoI quite like when games keep playing some visual-only animations when paused. Like torch flames and trees swaying in the wind.
- mjfisher 7mo agoThat's usually because the system that runs those things is independent of the timing of the main game loop. And then when someone finally gets around to implementing the pause screen, they still run even with the main game time stopped. And you look at it and think "eh, you know what - looks cool - we'll leave it".
- adrianton3 7mo agoTorch flames and trees swaying in the wind do not affect gameplay at all - they're most likely done in a shader and I think it's easier to keep updating a time uniform than to add extra conditions everywhere :D
- entuno 7mo agoAgainst the Storm (and excellent rouguelite city-builder) does this in a really cool way. Pausing is a core mechanic of the game, and you frequently pause while you place building or things like that - and all the visual animations stop (fire, rain, trees swaying, etc). But when you find a broken ancient seal in the forest, the giant creepy eyeball moving around in it keeps moving even when you pause the game, which helps emphasise how other-worldly it is.
- rahkiin 7mo agoI find it confusing: for me a clear indicator the game is paused is all animations also pausing. Some games do not pause in menu’s, for example. And some do, but not when in a multiplayer session
- nkrisc 7mo agoI think it really just depends on the game and what purposes “pausing” serves in that game. Take a game like solitaire, for example: there is no meaningful “pause” feature you could add, since the game state only advances in response to a user action. Other pause some underlying simulation while still letting you modify the game state, as an expected part of gameplay, like a city builder. As the user might spend a significant amount of time in a paused state building things, it would be pretty visually unappealing to have the entire world completely frozen the whole time. Others might pause all gameplay entirely, such as for displaying a menu, in which case pausing even environmental animations might make more sense since the user isn’t actively playing. For the second type, I would much prefer some GUI element to indicate the simulation is paused rather than freezing the whole game world, such as a border around the screen or maybe a change of color theme of the GUI or similar.
- Lerc 7mo agoI find the notion odd that this is even a problem to be solved. It suggests a level of control way below what I would ordinarily consider required for game development. I have made maybe around 50 games, and I think the level of control of time has only ever gone up. Starting at move one step when I say, to move a non-integer amount when I say, to (when network stuff comes into play) return to time X and then move forward y amount.
- recursivecaveat 7mo agoThe strangest pause bug I know is in Mario Sunshine: pausing will misalign the collision logic (which runs 4 times per frame) and the main game loop. So certain specific physics interactions will behave differently depending on how many times the game has been paused modulo 4.
- butvacuum 7mo agoreally? is one state the one where you fall through bridges? I can't play Sunshine because of that.
- zamadatix 7mo agoIf it's the one in Pianta Village there is a well known glitch on that one to do with watersliding over it. I haven't heard of a general bridge glitch though.
- positive-spite 7mo agoThere is another great one in one of the Legend of Zelda games. The game world is paused whenever Link pulls an item from a chest, but because his animation does not loop perfectly, because of a missing frame, he slowly slides across the ground and even through walls. One of the minimum % speedrun abuses this by looping the animation for many hours in order to glitch through a wall, and not collect a progression item, which would count towards the collection percentages.
- jwitthuhn 7mo agoMy favorite as a kid was also in a Zelda game. In the original (and maybe also DX) release of Link's Awakening, the game uses a top-down view with the world split up into tiles. Walking of the left side of a screen makes you end up on the right side of the next screen over. What you could do is pause at the right frame on the screen transition, and you would end up on the new screen but link's position would not change. So you walk off the left side of a screen and end up on the left side of the new screen. Lots of fun to be had with skipping important stuff with that.
- gobdovan 7mo agoWhen I present TLA+ [0], I am referencing game pauses (pause buffer / item duplication Legend of Zelda exploit, Dark Souls menuing to cancel animations) and deliberate crashes as mechanics to exploit games, as those are still valid actions that can be modeled, and not doing that allows such exploits to happen. A system is only correct relative to the transition system you wrote down. If the real system admits extra transitions that you care about (pause, crash, re-entry, partial commits), and you didn't model them, then you proved correctness of the wrong system. [0] https://lamport.azurewebsites.net/video/videos.html https://lamport.azurewebsites.net/video/videos.html
- Jach 7mo agoDo you have any of these presentations available publicly? I'm always amused by the glitch names people come up with (force quit wrong warps, skirtless parry-walks...) and it'd be fun to see them in a TLA+ context.
- dwroberts 7mo agoThe console cert ones are interesting but all the others are just Unity/Gamemaker/Unreal not allowing the developers to write normal code? The nonzero timestep thing is very strange
- jonahs197 7mo ago[flagged]
- xhevahir 7mo agoWhen I first played the NES the pause feature impressed me even more than did the graphics. Apparently Atari already had the feature on the 5200 console, but even as late as 1988 it felt like magic to hit a button, go and eat dinner, and an hour later resume my game with another press of the button.
- faangguyindia 7mo agoHow difficult can it be when Cloud providers are able to do live migration of VM from one bare metal server to another?
- tuetuopay 7mo agoLikely more difficult. Live migration boils down to copy memory over the network, stream the page faults till you converge enough, and resume execution on the other host. It’s not a hard problem but a precise and tedious one. Pausing a game might involve a lot of GPU contexts to freeze, network resources to pause, storage streams to pause, input handling, sound, etc. Add to that physics engine that may be tied deeply in the system and you end up with a hard problem. What a VM does is not the role of the hypervisor, thus it can apply its hammer that works in pretty much all cases, and VMs are pretty much all the same. On the other hand, all games are bespoke with custom plugins and custom integrations, which make them the opposite of "generic pause implementation".
- faangguyindia 7mo agothat's exactly what i wanted to know, trick works: be confidently wrong on web and get the right answer :D
- flohofwoe 7mo agoPausing a game is not as simple as freezing its entire state (and saving is also not as easy as dumping the entire game state to disc, at the least you'd end up with gigabyte-sized savegames). Many game systems need to remain active in paused state (the UI needs to remain working for example, and actions in the UI may also manipulate game state (inventory, crafting, levelling up...). There are also plenty of games with 'active-pause' where the user can issue commands to units while in paused state.
- SyzygyRhythm 7mo agoEarly versions of Unreal Engine had these animated procedural textures that would produce sparks, fire effects, etc. The odd part is that when you paused the game, the animated textures would still animate. Presumably, the game would pause its physics engine or set the timestep to 0, but the texture updater didn't pause. I suspect it was part of the core render loop and each new iteration of the texture was some sort of filtered version of the previous frame's texture. Arguably a very early version of GPU physics. Modern games can have the same issue. Even taking a capture of the exact graphics commands and repeating them, you'll sometimes see animated physics effects like smoke and raindrops. They're doing the work on the GPU where it's not necessarily tied to any traditional physics timestep.
- avereveard 7mo ago> when it was time to ship, we’d read the [Technical Requirements Checklists] and have to go back and add a special pause for when you unplug the controller article confirms my early theory I formed when reading the title about why would pause be complicated
- jFriedensreich 7mo agoI only know pausing games is funky because the highest my playstation fans ever go is pausing some games. Quite weird pausing is not just a feature of the game engine or runtime, especially as the menu and settings system seem to be totally separate in most cases anyways.
- teamonkey 7mo agoIt is a feature of most game engines. Unreal has a standard SetGamePaused function, for example. But like most things in game development there is no solution that fits every use case.
- gordian-mind 7mo agoI was suspicious of those random game developers getting quoted, and this is the pinned post of the one giving this cute silly story about slowing down game speed time: "Announcing TORMENT HEXUS, a match-3 roguelike about putting technofascist CEOs on the wrong side of skyscraper windows! [...] And remember: they SHOULD be afraid of us. #indiedev #indiegame" Weird times.
- delusional 7mo agoEh, I remember the myriad of both "Torture Bin Laden" as well as "Torture George Bush" flash games in the early/mid 2000s. I think it's very on brand for indie developers.
- gordian-mind 7mo agoI don't believe those are the same thing. Many people lately seem just frankly enthusiastic about political murders.
- cubefox 7mo agoBluesky has a lot of left-wing extremists where things like murdering CEOs is cool because they are allegedly "technofascist".
- esrauch 7mo ago"Evil megacorp" media is hardly new.
- cubefox 7mo agoMurdering CEOs is extremism, saying something is an "evil megacorp" is totally different.
- jodrellblank 7mo agoThere's probably something eloquent by Hannah Arendt about how 190,000 Americans killed by health insurance companies goes unnoticed while one person killing a CEO becomes a spectre of "left wing extremism" held up as an example. Or was it by The Joker from Batman? Or was it when protesters in Latin America sat down blocking a road to protest environmental destruction and an American driver was so angry that he was mildly inconvenienced that he got out of his car and murdered one of them with his gun. And Joe Rogan's podcast commentary was "what did they expect?", more annoyed at the inconvenience to drivers than the murder of a human. Or maybe when Just Stop Oil protestors threw soup and mashed potato on the glass in front of a painting, with the idea "look how angry you are at the damage to a valuable and irreplacable object, this is how angry you should be at the damage to the valuable and irreplacable environment which keeps all humans alive" and Fox News laughed at them for both damaging something important and not causing any real damage so they were ineffective. Then the judge gave them 2 years in prison on the grounds that throwing a can of soup at someone's face would be violence, so throwing it at a painting is violence. But no oil executives overseeing the Exxon Valdez disaster or the Gulf of Mexico disaster faced any jail time at all. Or when the suffragette movement cut a painting of Venus de Milo to protest against Emmeline Pankhurst being arrested and rough-handled, and people were angrier about the harm to the painting of a woman than about the harm to a real woman. Or when Fox News says "they aren't protesting the right way" so Kapaernik asked actual verterans how to peacefully protest respectfully and they told him to kneel during the national anthem, and the complainers didn't care a whit and said that was still the wrong way and disrespectable, and he lost his job and the president tweeted rude things about him personally, and the national football thingy made that kind of protest forbidden, almost as if the objection "protesting the wrong way" was all bullshit. Yes, probably Hannnah Arendt could put it eloquently. But you're right, murder is wrong, and that's all there is to it.
- otikik 7mo agoSo the simple case is using some sort of state variable: switch(game_state): case(paused): <the paused logic goes here> case(gameplay) <updating entities and regular gameplay goes here> You still have to be careful about how you implement "gameplay", though. For example if at any point you read the 'system clock' to do time-based stuff like animations or physics, then when you unpause you suddenly will have a couple minutes of advance in a place where you expect fractions of a second.
- diath 7mo agoThis is why delta time accumulator is preferred over using clocks, something like this would be best: float accum = 0; while (running) { poll_input(); poll_network(); accum += delta_time; while (accum >= tick_time) { accum -= tick_time; update_ui(tick_time); update_anims(tick_time); if (!paused) { update_entities(tick_time); } } render(); }
- setr 7mo agothe notion of using time directly in gamedev has always confused me; it feels like the correct answer should be to simply have a notion of turns, and a real-time game simply iterates over turns automatically. And then so many turns are executed per second It's a simulation; why should clock time be involved to begin with? The only things that should care about clock time are those that exist outside the sim, e.g audio
- maxbond 7mo agoSimulation can proceed in logical time but animation is necessarily tied to wall clock time in order to be perceived as smooth and consistent by a human viewer.
- setr 7mo agoIn that case, animation belongs to the same category as audio — it exists outside the simulation state. But I’m not 100% that’s even true; in the context of replay, I imagine it’d be more appropriately part of the sim for it to scrub properly. In the context of networked games with client-side prediction, I think it’d probably be key frames tied to logical time and intermediate frames tied to wallclock
- mylasttour 7mo agoThere used to be a funny bug in Dota 2: While the game is paused, if a player were to click on the "level up" buttons for their skills, each click actually advanced the game by 1 frame - so it was possible for people to die etc. during a pause screen.
- Sharlin 7mo agoI would expect pausing to bring a game’s CPU/GPU usage down to near-zero, which won’t happen if the game keeps redundantly rendering the exact same frame. A game engine can optimize this by special casing time scale zero to simply render a single textured quad under the pause menu (which is probably what one of the commenters in TFA referred to).
- qwery 7mo agoYou would expect it to do that, and I'd say that's a desirable behaviour, but it's not really that simple and you certainly don't get that for free. Typically any of the common modern engines with a "time scale" variable like that are not at all optimising anything in that way. It's likely that the physics engine won't be stepped with a zero delta time, which will reduce the time spent on physics, but that's more of a byproduct of how physics engines work[0] than an optimisation. You would have to go out of your way to capture the scene and display it "under the pause menu" in that way. Not saying nobody does that, just that it's not something the engine is giving you for free nor is it related to the time scale variable. Further, doing that won't necessarily reduce resource usage. For example, if there isn't some sleep time inserted in the main loop when in a menu, or v-sync[1] to limit the framerate, the result of the simplified scene (just the menu and the quad with the captured scene) is an extremely high framerate, which may or may not cook the hardware more than the in-game load. [0] Typical rigidbody physics engines are only (what I'll call) predictably stable with a constant delta time (same dt every tick). And a common way to manage this is with a time accumulator main loop, that only steps physics for whole units of dt. [1] And v-sync isn't a silver bullet. consider refresh rates, different hardware, different drivers, driver overrides.
- glaslong 7mo agoSpeaking of "capturing the scene and display it under the pause menu".... acerola on YouTube has an excellent 23 minute frame rendering analysis video about what goes into drawing just the "pause menu" in Persona 3 Reload: https://youtu.be/dVWkPADNdJ4?t=19m10s https://youtu.be/dVWkPADNdJ4?t=19m10s
- account42 7mo ago
- torginus 7mo agoOne of the things I was thinking about with regards to pause and or save games, is the need to control all aspects of real time logic, with possibly stopping/resuming, and saving it to disk is how our current ways of doing async is incredibly lacking. Unity has introduced the idea of coroutines (which were essentially yield based generators), and people started using them, and immediately encountered problems with pausing/saves. Internally these coroutines compile down to state machines with opaque internals which are not necessarily consistent across compilers/code changes, and its very difficult to accomodate needs like pausing when using them. From what I've seen, the usual answer is that people go back to hand-written state machines, and go through the pain of essentially goto programming to fix these issues.
- edflsafoiewq 7mo agoI understand why coroutines are an issue for saving, but why are they an issue for pausing? Don't you just not resume the coroutines while paused?
- glenneroo 7mo agoIt depends. If you are using `yield return new WaitForSecondsRealtime(x)` then the coroutine keeps running when you set TimeScale to 0, but that's usually a feature and not a bug, since it lets you potentially use them when paused (since async/task C# stuff was usually been a bit sketchy, though it's definitely better now). Some more info here (and in general about pausing in Unity): https://gamedevbeginner.com/the-right-way-to-pause-the-game-in-unity/ https://gamedevbeginner.com/the-right-way-to-pause-the-game-...
- lordmauve 7mo agoFrom a lot of game jam games with custom engines, I have a pretty standard approach: I set the game clock to zero timestep, and push a pause gamestate onto the gamestate stack, where top gamestate gets all input. The trick is that you need many clocks, clocks for the gameplay/game animations, HUD animations, menu animations.
- pcblues 7mo agoThis is silly reporting with a couple of interesting stories. Forget about the technical ways of doing it. Doing it at all changes the game experience. Pausing a game has a massive impact on the game experience. It lets you break the fourth wall experientially. Not wrong, but it changes the dynamic of the game. Same as saving at any time does. As losing your loot or your life permanently does. Not wrong, but a hard choice that appeals to some players and not to others. I used to pause pacman on my Atari 800 so I could run to church and sing in the choir or be an altar boy. Then I ran home and unpaused to continue. Sometimes in summer the computer over-heated and I lost everything while I was at church. Lessons learnt? None, I think :)
- account42 7mo ago> Same as saving at any time does. As losing your loot or your life permanently does. Not wrong, but a hard choice that appeals to some players and not to others. That choice should be left for the player.
- marcosscriven 7mo agoThis reminds me of the Action Replay device you could get for the Amiga 500 in the ‘90s. You could use a knob to slow down any game to a stop. You could also press a button to go to a console that let you change memory. It would even figure out which bit of memory kept the number of lives of you deliberately lost a life and it could see what decremented.
- raincole 7mo agoMore people should play Lobotomy Inc. Coolest pause mechanism I've ever seen.
- insraq 7mo agoI am recently working on a "realtime with pause" style grand strategy game using my own engine (think Europa Universalis, Crusader King, Hearts of Iron). The trick is to separate the logic simulation from other game loops (rendering, UI, input, sound, etc). So when a player pauses the game, everything else still more or less works. And the logic simulation should be able to take user "command" while being paused. Most commands should mutate the game state and reflect in the UI immediately. A few commands that have to wait until the next tick should at least acknowledge the action result.
- Folcon 7mo agoHey, I'm working on a grand strategy game as well based on a fictional setting, would love to chat and compare notes if you're open to it, my email is in my profile
- ninkendo 7mo agoI’d love to hear about the 2020 release of Microsoft Flight Simulator, which had an “active pause” feature that they hyped as a big innovation for that release. You could pause and switch camera angles and see what was going on, then quickly resume. Pretty much the whole game was still interact-able, but with your plane’s position paused. It was supposed to be a nice user-friendly way to pause while you checked gauges or fiddled with cockpit settings or whatever. It never worked. You’d pause, and the plane was frozen in place yes, but the instrument cluster would still animate and show your altitude/speed changing as if you never paused. But you couldn’t control anything until unpaused. So you’d resume, and your momentum would suddenly leap to where the accumulated deltas ended up. So if you active-paused at full throttle, you’d unpause and start going way too fast… if you active paused while stalling, you’d unpause and your speed would be near zero… you’d even consume fuel while paused. It’s like they literally just froze the plane’s position and left every other aspect of the physics engine untouched, never tested it, shipped it, and even did a bunch of marketing at how great the feature was. When it was so obviously broken. I came back to the game after a year or so of updates, and not a thing had improved, it was every bit as broken as when they shipped it. The 2024 release seems to have largely fixed it though from what I can see. It’s just nuts they had such a clearly broken feature for that long.
- deleted 7mo ago[deleted]
- shmeeed 7mo agoI was going to comment on MSFS2020's Active Pause as well. It's a curious implementation, but I always assumed the behaviour was intentional. After all, there's a "regular" pause mode as well. You gotta learn and understand its quirks, though. As long as your flight state is rock stable (e.g. on Auto Pilot) and/or you're not fiddling with the controls while paused, it's pretty much always worked fine for me. I've also used its interactivity to my advantage and saved the plane from an otherwise unsaveable flight state, e.g. by gaining airspeed while paused.
- shakow 7mo ago> which had an “active pause” feature that they hyped as a big innovation for that release So my memory might be playing me a trick, but wasn't that already the case in FS2002 and 2004? I seem to remember using the pause as a kid to look at my plane under every angle.
- qwery 7mo agoLike a lot of issues in gamedev, pausing the game is a surprisingly difficult problem to solve. It's especially difficult to provide a one size fits all solution which would obviously be desirable for the popular modern engines that try to be a general solution. I see a lot of comments here saying something along the lines of "isn't it just a state in the state machine?" which isn't wrong, but is an extremely simplistic way of thinking about it. In, say, 1983, you could get away with something like that: - pause the game: write "PAUSED" to the tilemap - paused main loop: check input to unpause - unpause the game: erase the "PAUSED" / restore the previous tiles But at that time you could already see the same sort of issues as today. Something somewhat common in Famicom/NES games is the sprites disappearing when the game is paused. Perhaps deliberate/desirable in some cases (e.g. Tetris) but a lot of the time, probably just a result of the 'is paused' conditional branch in the main loop skipping the sprite building code[0]. There's an extremely large problem space and ultimately, each game has its own way to define what "paused" actually means. You might be interested in the features Godot provides[1] for this. Particularly, the thing that makes it interesting is the 'process mode' that each node in the scene tree has. This gives the developer quite a lot of control over what pausing actually means for a given game. It's not a complete solution, but a useful tool to help solve the various problems. [0] Simplified description of course. Also, the sprite building code often ended up distributed throughout the various gameplay logic routines, which you don't want to run in the paused state. [1] https://docs.godotengine.org/en/stable/tutorials/scripting/pausing_games.html https://docs.godotengine.org/en/stable/tutorials/scripting/p... [ed] Just adding that Tetris is only an example of a game where you might want that behaviour, not a comment about how any of the Tetris games were actually made.
- an0malous 7mo agoI read your comment and the article and I’m still not really clear on why this isn’t as simple as saving the current state or pausing the render or time loop.
- jayd16 7mo agoSaving the current state? What does that even mean? You don't save transient things like visual particle positions but it's something you expect to persist between pauses. Pausing the render? But not the physics so you keep falling? You need to pause many systems. At the very least you'd want to pause gameplay, and sound and physics. You'd want to keep input and some of the UI unpaused. If you have a fancy UI with VFX, you need to make sure those are not using the paused game time. etc etc
- effdee 7mo agoIf your game uses more than 1% CPU and 1% GPU when paused you're doing something wrong. A damn blurred screenshot should not make the GPU consume hundreds of Watts.
- Aurornis 7mo agoPaused game does not equal paused process. It means the gameplay clock has paused. The rendering loop continues to run. The GUI is immediate mode and is still rendered. In some games visual effects continue to be rendered. If it’s a networked game the network code will continue to run.
- dataflow 7mo agoI think the parent comment still ought to stand. Unless you're saying it's literally infeasible for some reason, which I find hard to believe?
- daemin 7mo agoA paused game is not like a paused video where there is no processing going on. A paused game still has all the rendering usually going on (unless the developers got time to implement something custom), audio still needs to continue, the only thing actually paused in the game logic and gameplay elements. Given this the game needs to slow down and lock its frame rate while paused and in menus otherwise it will run at full speed and burn a lot of CPU & GPU time. Though I would say this is not usually an issue because it gets fixed pretty quickly during development. Now more work can be done by the developers to make the paused state this efficient, but it is all a matter of priorities, and in all cases the developers would rather spend their time making the gameplay better and fixing crash bugs. If the player wants their game to run more efficiently then they should reduce the processing demands by limiting the frame rate and lowering quality settings.
- dataflow 7mo agoYes, I already understood all that. > unless the developers got time to implement something custom As I said: the point nevertheless ought to stand.
- intsunny 7mo agoSuddenly I realize why so many games didn't have a real pause feature, but a view maps feature that did the same.
- umvi 7mo agoSeems like a solved problem for consoles, at least. On the Nintendo switch you can "pause" any game regardless of if the devs implemented it by pressing the home button which suspends the entire game at the OS level
- stanko 7mo agoThat is different, because you can't interact with the game anymore. In game pause can let you change your settings or map for example. Menus and map are still running in the game loop, so then you need to make they get the input events but not the gameplay part.
- jayd16 7mo agoIf by solved you mean it's a feature you're required to support... It can never be truly seamless when things like wall clock or device state (SD card is missing suddenly) or network connections disappear.
- glenneroo 7mo agoNintendo, like all other platform-owners (e.g. Meta/Quest, Sony, Microsoft) is VERY strict about games released on their platform and have very strict requirements before anything is allowed to be sold with the Nintendo label. I very highly doubt they let devs NOT implement the pause ability. AFAIK you can't just OS-pause a game and expect it to run fine when it resumes, there are soooo many systems at play: animation, physics, sound, input, etc. that need to be cleanly stopped/resumed that I doubt it's as easy as just OS-pausing.
- Jach 7mo agoThis used to be true, but one trip to any modern e-store front should dispell the notion. So much slop. Even for arguable non-slop, so much that just rapidly crashes and is unplayable. The extent of platform certifying these days for most titles seems to be: can launch, can back out to the console top level, and maybe doesn't crash if a controller is added/removed.
- netcoyote 7mo agoOne of the fun features that I developed for Warcraft (the RTS) was to fade the screen to grayscale when the game is paused. Since the game uses a 256 color palette, it was only necessary to update a few bytes of data (3x256) instead of redrawing the whole screen, so the effect was quick. I also used this trick when the game stalled due to missing network packets from other players. Initially the game would still be responsive when no messages were received so that you could still interact and send commands. After a few seconds the game would go into paused state with grayscale screen to signify the player that things were stuck. Then several seconds after that a dialog box would show allowing a player to quit the game. This was much less disruptive than displaying a dialog box immediately on network stall.
- KellyCriterion 7mo agoPalette rotation was also heavily used by Ultima & Origin games up to U8 - Pagan
- herodoturtle 7mo agoThis was a neat design choice I remember it well. And also that my “sound card works perfectly!”
- RobRivera 7mo agoOmg I love this! I have been finding excuses to do little animation engine features that arent on the critical path of development for the sake of creative self-indulgence. Such features shipped was alpha channel based fading using the fundamental opengl fade parameter (under the hood its a linear interpolation of alpha values over 256, pieced together over a provided pair of timestamps). I tell you what I'll do today on my dev time, I'll try implementing grayscale without aby research on pause and then compare notes (I'm assuming this wc code is available somewhere, which may be a bad assumption)
- bombcar 7mo agoWC code is likely not (legally) available, but Wolfenstein and Doom both did similar palette tricks and are documented in the Black Books for each - https://fabiensanglard.net/three_books_update/index.html https://fabiensanglard.net/three_books_update/index.html Code for those is available.
- groundzeros2015 7mo agoCan we just link to the twitter thread the article copies content from?
- hanisong25 7mo ago[dead]
- RobRivera 7mo agoTotal self brag, one of the key foundations of my game engine is that every single instance of any object has an anchor to a timing system, and pausing can be propogated on the same cycle as the input-capture at the most granular level as desired. I really need to start blogging my notebook
- MrGuacamole 7mo agoOne game that I thought had a great "pause" feature was Dragon's Dogma, you can pause the game mid fight to use items that heal or remove status effects. At first I felt this was kind of cheesy, but due to the games inventory weight limits it actually made traveling long distance or tackling dungeons more strategic because you had to bring the appropriate items for the enemies you'd be facing and use them sparingly or you'd be in trouble. Further into the game it actually felt like it required more strategy and planning, I thought it was pretty great game design and really liked it.
- sombragris 7mo agoThe ability to pause is extremely important in games (at least single player ones). I hate when games are into multiplayer modes even when played in single-player campaign (e.g.: Generation Zero) and thus cannot be paused. Another thing that I hate in this regard are unpausable cutscenes. I remember when I was playing The Witcher 3, that at last there was some cutscene advancing some plot point, and right into the middle of it The Wife™ would barge in telling me something important that would require my attention... but I cannot pause that scene so I had to miss it while I listened to her. Why, oh why, devs hate pausing cutscenes so much??
- account42 7mo agoThe worst part is that often enough the pause key (e.g. Escape) skips the cutscene so it's a risk to even try pausing them.
- pmarreck 7mo agoI would prefer to understand why a paused or backgrounded game still manages to consume a ton of CPU or GPU Like, you're still just churning away at the main game loop while literally nothing else is happening except for you waiting for me to unpause it? Because THAT would be an actual achievement. Hell, I can suspend any process from the Unixy side of things by sending a SIGSTOP signal, for a far more perfect "pause". If I was a game dev, I would not settle for "looks like paused, but still burning down the environment and heating up my home as a side effect"
- MrGilbert 7mo agoBut if you were a game dev, you would understand why it‘s not as easy as it seems to outsiders. :)
- pmarreck 7mo agoI'm not saying it would be trivial, but I bet that once you figure out a workable pattern, you could replicate that on other games. One idea that might be relatively easy to implement- Slow the framerate down to something super slow instead of fully stopping
- thunderfork 7mo agoAh, but now your pause menu feels like total garbage to use!
- account42 7mo agoYou can adjust the frame rate based on whether the user is actually interacting with the window and whether the window is currently not shown at all. This is not hard to do at all, burning CPU and CPU cycles just to show a static frame (or nothing at all while the window is minimized) just means the developer doesn't care.
- GuB-42 7mo agoBecause the engine is still running, even in a paused state, the game still has to show something and process input. Sometimes there is a menu too, sometimes the game is not completely frozen: flames may flicker for instance. In the article, there is a case where the game takes a screenshot and disable costly rendering, presumably to deal with this problem. But the thing is that most games are designed to to be actively played, not paused for extended periods of time and having an active pause for a couple of minutes isn't going to destroy the environment. For backgrounding, is is common for games to run at a much slower framerate to save resources.
- varunramesh 7mo agoPausing is unintuitive in Unity because you don't control the main loop - all active objects get updated every frame. The recommended way to do it is to set the "time scale" to zero and have menu animations use special timers that ignore time scale. If you control the game loop, you can usually just get away with an "if (paused)" [0]. [0] https://github.com/rameshvarun/marble-mouse/blob/8b25684a815307f62e8320911841ca451d87d9e2/src/gameplay/level.ts#L712 https://github.com/rameshvarun/marble-mouse/blob/8b25684a815...
- DonHopkins 7mo agoScriptX had a clock hierarchy, similar to a 2d or 3d transform hierarchy, but instead of each node just inheriting and modifying translation/scale/rotation, they also inherited and modified the "timebase" (time offset and scale). https://en.wikipedia.org/wiki/ScriptX https://en.wikipedia.org/wiki/ScriptX So time scale 0 meant paused relative to the parent time scale, and time scale -1 meant time flowed backwards, which was actually quite useful! https://news.ycombinator.com/item?id=41283223 https://news.ycombinator.com/item?id=41283223 DonHopkins on Aug 18, 2024 | root | parent | next [–] The QuickTime API supported reverse play around 1993 or so, when I enjoyed using it for "back and forth" animated sprites, and playing music videos backwards to reveal the satanic messages with demonic backmasking. Reverse / Backwards Moonwalk - Michael Jackson - Better Than The Original!!! https://www.youtube.com/watch?v=IT_Aq2FjJo0 https://www.youtube.com/watch?v=IT_Aq2FjJo0 Here's the documentation and code I wrote when working at Kaleida Labs (a joint venture of Apple and IBM) on a ScriptX animation library that used QuickTime and other renderers, and depended on QuickTime's support for playing videos backwards, and single stepping forward and backwards of course: ScriptX Animation Library: https://www.donhopkins.com/home/catalog/lang/scriptx/anim.html https://www.donhopkins.com/home/catalog/lang/scriptx/anim.ht... ScriptX Animation Implementation Module: https://donhopkins.com/home/archive/scriptx/animimp.sx https://donhopkins.com/home/archive/scriptx/animimp.sx ScriptX's QuickTime renderer would even play audio backwards and at whatever speed, too. ScriptX had excellent multimedia clock synchronization, and we would have considered it a terrible bug if ScriptX was not able to seamlessly and transparently synchronize video and audio with any arbitrary clock, time offset, and time scale, no matter what the speed and direction. I'm sad that 31 years later, web browser video and audio players (not to mention VLC) don't support hierarchical clocks like ScriptX did for multimedia synchronization. (Each child clock can have a time offset and time scale relative to its parent, and everything's automatically kept in sync, from the simulation to the renderer.) Here is Kaleida's (then Apple's) 1993 patent on "Synchronized clocks and media players", which has long since expired in 2013: https://patents.google.com/patent/US5452435A/en https://patents.google.com/patent/US5452435A/en >Abstract: A media player and the clock which controls it are integrated into a single object. This integration may be achieved by the construct of inheritance between objects in an object oriented programming environment. A software class for player objects is established which inherits from a software class for clock objects. In this way, a player "is a" clock. This integration provides improved synchronization among different media, and simplifies design of applications which employ player objects and clock objects. Each object is synchronized to a RootClock object which operates at the speed of the fastest media player in the system. The RootClock may be separated into "low" order and "high" order components and a compare register in order to reduce interrupt overhead. >[...] QuickTime essentially allows a multimedia player to process timebased data. Since the data are time based, QuickTime provides for the description of "time" (called time basis) for the data as well as a definition of the context for evaluating that "time." In QuickTime, a movie's or media's time basis is called its "timebase." >A timebase is essentially a vector that defines the direction and velocity of time for a movie or media. The context for a timebase is called its time coordinate system. Conceptually, a time coordinate system provides an axis for measuring time. The time coordinate system, like a geometrical axis, is divided into units of measurement by a measurement system, called a time scale. [...] https://news.ycombinator.com/item?id=18781950 https://news.ycombinator.com/item?id=18781950 DonHopkins on Dec 29, 2018 | parent | context | favorite | on: Steve Jobs hired a career juggler to teach program... Oh, of course I wish Apple and IBM had made it free! But it included Apple's "crown jewels", the QuickTime player source code, and they were't going to give that away in 1995. Apple were even trepidatious about IBM having access to that source code. Besides having proprietary decoders, it could also do some things you can't even do well with the Flash player or html video component today: like smoothly playing videos and music backwards! Ever since the music industry switched from vinyl to CD, listening to demonic backmasking in Devil Music like the Beatles and Led Zeppelin's promotion of Satanism became much less convenient. ScriptX solved that important problem elegantly with its synchronized clock system, but today's HTML video player still hasn't, alas. https://en.wikipedia.org/wiki/Backmasking https://en.wikipedia.org/wiki/Backmasking https://www.youtube.com/watch?v=5BDh_j5qAJ4 https://www.youtube.com/watch?v=5BDh_j5qAJ4 Here's a description of ScriptX's clock system: https://news.ycombinator.com/item?id=18350511 https://news.ycombinator.com/item?id=18350511 >Kaleida Lab's ScriptX (a multimedia programing language kinda like Dylan with classes) had built-in support for hierarchal clocks within the container (in the sense of "window" not "vm") hierarchy. The same way every window or node has a 2D or 3D transformation matrix, each clock has a time scale and offset relative to its parent, so anything that consumes time (like a QuickTime player, or a simulation) runs at the scaled and offset time that it inherits through its parent container. And you can move and scale each container around in time as necessary, to pause movies or simulations.) You could even set the scale to a negative number, and it played QuickTime movies backwards! (That was pretty cool in 1995 -- try playing a movie backwards in the web browser today!) Is it possible to play HTML5 video in reverse? https://stackoverflow.com/questions/5277293/is-it-possible-t https://stackoverflow.com/questions/5277293/is-it-possible-t... Kinda, but it's not smooth enough to sing along while dancing backwards and worshiping Satan to: https://codepen.io/adrianparr/pen/qmCek https://codepen.io/adrianparr/pen/qmCek
- yawnxyz 7mo agofor our game dev project in undergrad we built an rts game as our capstone, and we used the "slow stuff down" trick - except different systems had different clock/time systems! and so some things were still running while it was paused, which led to some weird side effects (eg money glitch) i did the thing you're "not supposed to do" and attached everything to a world clock so everything ran at like 60fps in terms of events, so it was a real-time "turn based" system
- glenneroo 7mo agoToo bad they didn't ask any VR developers. It's truly another beast, especially if you're developing with Unity for the Quest platform, since setting TimeScale to 0 in Unity effectively disables the physics engine, which means things like hands/controllers no longer work, which then breaks one of the requirements to even be able to release in the Meta store (handle pause state). The workaround used by Half-Life: Alyx (as told to me by the Hurricane VR developer when I asked years ago how to deal with pausing) is to clone your hands and disable/delete all physics-related stuff (e.g. Rigidbodies) on the new "paused" hands. If you are using laser pointers, then you'll also have to switch those out as well. If you have any active effects, particles or objects that obstruct the player's vision and/or visibility of the pause/resume UI, then you'll want to either disable those out or at least dim them substantially so the player can interact with the resume button e.g. with a laser pointer. You might also want to adjust the lighting to indicate that the user is paused. Outside of VR, Unity offers a nice "AudioListener.pause" to pause all audio, but if you have any sound effects in your pause menu like when a user changes a setting, those no longer work, further requiring more hacky fun (or just set it to true, and ignore user-complaints about no audio on menus when paused). On top of that, you have things like Animators for characters, which also have to be paused manually by setting speed to 0 (TimeScale = 0 doesn't seem to do it). Some particle systems also don't seem to be affected by TimeScale. If you have a networked game then you also have to (obviously) send the pause command to clients. If you have things in motion, pausing/restarting the physics engine might cause weird issues with (at least angular) velocity so you might have to save/restore those on any moving objects.
- Panzerschrek 7mo agoPausing a game is a source of many bugs. In many games some subsystems aren't paused, like particles or animated materials. In some games I even saw that the character moves forward if the forward moving button was pressed at the moment when the pause button was hit. It surprises me, that it's so hard to do properly.
- animal531 7mo agoYou also often need several tiers of pausing. For example when paused you want the current game time to be zero, but you also want to ignore only some user inputs. You don't want to disable the menu or pause/unpause actions along with player actions, also you might want to pause dialog but not music (although you might alter it for the menu). Then there are others such as vfx that can have their own tiers, you might have something in the background that is difficult to pause, stop and/or resume. Then there are other things such as timers etc. that will need special handling, graphics card interactions etc. When done with those you also need to be able to resume and ensure that all of the previous will continue as if nothing have ever happened. In the same vein some other "simple" things like saving/loading the game is often anything but.
- MarchApril 7mo agoI've been writing toy examples with raylib to OpenGL and my DIY pause solutions were usually so bad. I'm glad they wrote more than just "click this GUI button to access pause state" in a ginonmours game engine