logoalt Hacker News

danhauyesterday at 7:38 AM2 repliesview on HN

The 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).


Replies

torginusyesterday at 10:11 AM

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

kdheiwnsyesterday at 9:46 AM

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