Live data from Hacker News

Game devs explain the tricks involved with letting you pause a game

kotaku.com

211–220 of 273 posts

Re: Game devs explain the tricks involved with letting you pause a game

#211

One 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 pa…

I 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?

Re: Game devs explain the tricks involved with letting you pause a game

#212
Too 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.

Re: Game devs explain the tricks involved with letting you pause a game

#213

One 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…

Oh, and I forgot to mention that pause had to be synchronized across the network, so the pause button would pause for all players. And in the "this is why we can't have nice things", that also introduced problems, because we didn't want a player who was losing to keep pausing the game until the winning player quit out of frustration, so I think we kept a per-player pause counter, which would only be restored if other…

I remember something like this back when playing StarCraft (maybe Brood War, it's been a minute) online.

Re: Game devs explain the tricks involved with letting you pause a game

#214

Earlier quoted context omitted.

Omg 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 toda…

While I don't have the original code, it's something along the lines of this: // for each palette entry: pal.r = pal.b = pal.g = (byte) (0.299 * pal.r + 0.587 * pal.b + 0.114 * pal.b)

I havent gotten behind the console, but thats like, exactly what I was gonna do, except precompute like 5 or 6 tween values for r,g,b between 255 and the target for greyscale.

But rather than do that and cache them for timing triggers, I kind of like the scaling down by multiplication approach.

Edit: manipulate the rgb values that is - I wouldnt have converged on those hard values on my own.

Re: Game devs explain the tricks involved with letting you pause a game

#215

Earlier quoted context omitted.

Physicians For A National Health Program put the figure at 200,000 people annually[1]. What's your source for saying the number is zero? When they deny claims, people die. When they override medical doctor recommendations and insist on cheaper treatments, people die. When they tangle up customers with paperwork and bureaucracy, that some people can't access the health insurance they pay for. When they take money out…

> Physicians For A National Health Program put the figure at 200,000 people annually[1]. What's your source for saying the number is zero? I'm not saying the number is zero. I'm saying the number is vastly negative. They are overall saving a lot of people rather than killing them. Health insurance companies are hugely net-positive. > but sticking a label on it and saying "leftist extremism" and then denying real issu…

Compared to no healthcare at all, yes, but similar could be said of Crassus' firefighting service in ancient Rome. He brought his slaves to your burning property and they stood around outside while you negotiated selling your property to Crassus at a bargain price. If you agreed, he ordered his slaves to fight the fire and you got some money. If you didn't, they let it burn and you got nothing. Crassus would be there to buy the ruins for even less if you couldn't afford to rebuild. That's a net positive for Rome compared to no fire service - fires don't spread to other buildings as often, people get something instead of nothing - but it's hardly a ringing endorsement, and it could be better.

Observation 1: you are bothered by the murder of the CEO. You dismiss the business-as-usual harms to hundreds of thousands of poor people. You consider yourself to have a good grasp of what is crazy.

Observation 2: when faced with claims that insurance companies kill people, you turn to dreaming of a world where you can talk of killing Democrat leaders. You still consider yourself to have a good grasp of what is crazy.

Complaints, letters to the editor, letters to congresspersons, achieved nothing; the murder of a CEO has achived nothing; what size event would make you notice?

> "Imagine I believe that the Democrats are net-negative"

Just feels important to say, for the record, that facts don't support that position; the Economic Policy Institute[1], and the Senate Joint Economic Committee[2] found that since 1949 the economy performs better under Democrat administrations than under Republican administrations. Job growth is greater. GDP growth is faster. Unemployment is lower. Small business creation is higher. Manufacturing investment is higher. Stock market returns are higher. Wage growth is faster. Recessions start less often.

> "Would this justify people saying that Democrat leaders should be murdered?"

First problem here is your implication that I would support the Democrats being awful and not be on the side of people objecting [although not calling for murder]. Second is the implication that I would want to silence your free speech instead of, say, supporting your right to say things I disagree with, or sarcastically mocking you. Third (or really, first) problem is that you're replying to claims that insurance company behaviour causes humans to die with "Left bad".

[1] https://www.epi.org/press/new-report-finds-that-the-economy-...

[2] https://www.jec.senate.gov/public/index.cfm/democrats/2024/1...

[3] https://en.wikipedia.org/wiki/U.S._economic_performance_by_p...

Re: Game devs explain the tricks involved with letting you pause a game

#216
post #194

Earlier quoted context omitted.

I 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.

Saving 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 VF…

And if you pause sound in Unity using AudioListener.pause = true, which is supposed to make life easier, but ends up being useless if changing settings/clicking buttons has audio feedback, or changing the volume has audible feedback to tell you how loud, or you allow to change voice style, and on and on.

Repeat that for every system - all those edge cases for each system can waste a lot of time and energy.

Re: Game devs explain the tricks involved with letting you pause a game

#217
post #51

One 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 s…

It wasn't really that much to do with determinism. Quake uses a client-server network model all the time, even when you're only playing a local single-player game. What the demo recording system does is capture all of the network packets that are being sent from the server to the client. When playing back a demo, all the game has to do is run a client and replay the packets that it originally received from the server…

[dead]

Re: Game devs explain the tricks involved with letting you pause a game

#218
post #154

Seems 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

Nintendo, 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.

Re: Game devs explain the tricks involved with letting you pause a game

#219
post #14

Earlier quoted context omitted.

I had a puzzle game were all of the solutions it would show were playbacks of my keypresses as I solved it myself. As the puzzles got more difficult it got harder and harder to record a solution without having pauses to think about what to do next.

I don't mean this in an "I know better" way, just genuine curiosity: why couldn't you record a solution with pauses and then strip them from the replay file?

I tried but the change in behaviour immediately before and after the pause could be seen in the playback.

It's the time it takes to go "uhh, I'm stuck, I'd better pause" and then the bit before your brain kicks in following a pause.

Re: Game devs explain the tricks involved with letting you pause a game

#220

Earlier quoted context omitted.

Checking 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.

I 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.

[deleted]
Post reply on HN