How do games like Prince of Persia manipulate time? | Bitwise

  Рет қаралды 16,230

DigiDigger

DigiDigger

Күн бұрын

Manipulating time at will is in my opinion one of the most interesting and powerful feeling game mechanics.
Games like Prince of Persia, Braid, Qauntum League and even Overwatch employ time manipulation mechanics. But how does it work? How do games manipulate time? How can you rewind the entire world, speed it up and slow it down?
In this video I will go in-depth into the inner workings of Time Manipulation in games.
Timestamps
0:00 Intro
1:05 Update loops and time steps
4:30 Global time rewinding
8:24 Local time rewinding
13:12 Optimizations
15:15 Conclusion
My patreon: / digidigger
You can listen to our podcast at:
/ @publicvoidupdate
open.spotify.com/show/7ak1IV8...
podcasts.google.com/feed/aHR0...
or wherever you listen to podcasts
Music in in outro:
Besus y Abrazor - Rolemusic: freemusicarchive.org/music/Ro... available under a Creative Commons Attribution license creativecommons.org/licenses/...

Пікірлер: 73
@real_vardan
@real_vardan 10 ай бұрын
That's very insightful, the "zipping" method in the OG prince of persia trilogy abuses the limitation of the method. Where your character's movement/action is only stored for a maximum number of 20-ish action. If you do more actions than the maximum in a short amount of time and you start rewinding, the games would start glitching and teleports you forward, allowing you to past through locked doors or skipping a large gap.
@olik136
@olik136 9 ай бұрын
in GTA Vice City speedruns they use the replays to change stuff since the replays are not only videos but made in engine and some properties can be transferred from the replay to the current position/time. I forgot how it actually works but it looks pretty wild
@Yipper64
@Yipper64 10 ай бұрын
6:40 ok I just realized something really clever with TOTK's rewind. So when you rewind you see a ghost of the object at regular intervals. I think this is one of those hard save points that isnt interpolated. I dont think its *every single one* but that is extremely clever to use the position they know it was at, that they are going to place it back at, and make a ghost of that point.
@atlev
@atlev 10 ай бұрын
I'm surprised the video didn't mention TotK. Perfect implementation.
@gerardromero9850
@gerardromero9850 10 ай бұрын
I also thought of TOTK, but because in one of the puzzles I had a cube move touching side to side with the wall and going around a 90 deg. corner. This, as I understand now after this video, made the game tilt the cube unintentionally with an almost but not perfect interpolation of 'saved frames'
@TheMemoman
@TheMemoman 10 ай бұрын
I cannot explain how hard the Belgian techno anthem Pump Up The Jam joke you inserted here landed with me. Just a huge roaring reception over here. I watched Cunk On Earth last week, and today for some reason I've been pestering my wife with that joke all day. Explaining it, showing it to her, playing the song. And to so abruptly find it here in the midst of a great technical explanation was just perfect. 10/10.
@opelfrost
@opelfrost 10 ай бұрын
a lot of info in this video here is wrong i worked on a student project called chrono disfunglement so we rebuild braid time rewind in 3d you dont store key frame data only, you store key frame data and then you store the difference of each frame. the reason behind storing the difference instead of the key frame is due to reduced bit space required to store it. for e.g. if your data is an integer the difference in key frame 1 and key frame 2 is usually way smaller than a integer, that's how you store less data. think of it as a lossless video file compression, the concept is the same there are key topics that isnt touched too, for e.g. how do you handle particles system cause those require randomisation. one way is to use graph since graph is continuous but a long enough graph (that doesn't repeat itself) would look random to a user you don't use delta time either since that causes driff, you need to use fixed update, to speed up or slow down you just call it more or less times in a period go watch the vid made by braid creator, all the info to build a time rewind game is there
@wChris_
@wChris_ 10 ай бұрын
There is also FixedUpdate() which fixes an issue on really fast computers, where deltaTime can be so small it introduces large rounding artifacts. Its also called in line with physics updates. This means if you update physics in Update(), it could happen that partial state is displayed on screen.
@zxuiji
@zxuiji 10 ай бұрын
You can also improve performance by using looped linked lists for the object data, just make sure everything is pre-initialised when you start a scene etc so that if a rewind happens straight away it just rewinds to it's start position, no need to check if you're out of list bounds because you just loop back to start/end seemlessly
@PapoochCZ
@PapoochCZ 10 ай бұрын
Also known as circular buffers. Better to use fixed-size arrays though than linked lists for both memory and performance gains.
@zxuiji
@zxuiji 10 ай бұрын
@@PapoochCZ Depends on use case, in this case yeah, fixed size is better for time manipulation, however I would not store positions but rather the amount of time's worth recorded, velocity, rotation & increment amounts to add (so for example object->velocity += time_point->velocity, object->inc_velocity += time_point->inc_velocity, loop object->velocity += object->inc_velocity until next time point). Yes it would take more memory but it would also allow storing more time's worth of data for less than the equiv in positions etc
@kappascopezz5122
@kappascopezz5122 10 ай бұрын
I've had my own thoughts about reversing time, where instead of saving everything that happened in the past, you make use of the laws of physics being reversible, so you basically just need to invert the velocity of every point mass, and in theory everything should play out in reverse. When writing this as a game, things break down pretty quickly because things usually aren't actual point masses, and the game physics probably don't match real physics and therefore may not be reversible, so you would need to basically custom-write the physics for how things behave when they're reversed. But I think if you do manage to do something like that, it behaves quite differently from what's described in this video. First of all, there would be no passive performance drain from constantly saving all the data from every object, so this could scale very differently. Then, what I think is the main difference, is that it would be possible for a currently reversed object to behave differently from what it did originally, for example when another object that it would "reversely interact" with isn't there to have the interaction with. Just that mechanic probably would be pretty interesting to build a puzzle game around.
@oglothenerd
@oglothenerd 8 ай бұрын
You have inspired me to make a low poly, open source, time manipulation game!
@MarkedThing
@MarkedThing 10 ай бұрын
I adore your channel, you helped me out a lot!
@AS-ym2bp
@AS-ym2bp 10 ай бұрын
I've always wondered this for a long time after playing the Prince of Persia series but not being educated in game development I never really knew where to look for answers!!
@XxguaxinimxX.
@XxguaxinimxX. 10 ай бұрын
that was a nice video! Your explanation and edit made it easier to understand!
@yuriterra1
@yuriterra1 10 ай бұрын
Man, i love your videos so much. All your videos are awesome congratulations
@ralseithelonely
@ralseithelonely 10 ай бұрын
This video came up at the perfect time, as I've recently been thinking about how one would implement time travel into a multiplayer game. Though, I was wondering whether it would be possible to include player perception into it as well. (Player 1 stops time, but player 2 sees only the other teleport.) I only theorise as I am not a game dev, but I think the trick would be in sending both players out of sync data from the game server.
@DigiDigger
@DigiDigger 10 ай бұрын
Timebenders was exactly that, a time traveling multiplayer game. What I can say is: do not make this, it's a pain to program and you will question why you ever got into game dev in the first place :') Conceptually you need to think about what happens from the perspective of the other player when one player stops time locally. I think your interpretation would make sense, except for what happens with the other players. If one player freezes time around them, then everybody else would not be able to move. If that player then moves somewhere else and resumes time, from the perspective of everybody else that player would indeed "teleport". If it's more of a "local" time freeze then I suppose only players within its radius would perceive it as a teleport. Everybody else would just see that player walking around normally I suppose. It's kinda hard to wrap your head around, but this is what would make sense to me at least.
@GlyphicEnigma
@GlyphicEnigma 10 ай бұрын
This is an excellent explanation of this mechanic!
@cookingastronaut4429
@cookingastronaut4429 10 ай бұрын
Thank you for recommending Braid. That was my first Indie Game i've played back then and i really loved the mechanics there ❤
@AlanZucconi
@AlanZucconi 10 ай бұрын
As someone who published a time travelling game on console, this video evokes very painful memories. 😂
@lineikatabs
@lineikatabs 10 ай бұрын
Convergence: A League of Legend Story is a must play when it comes to time manipulation. A metroidvania where all the time you can rewind time, use various time powers to fight and traverse. It's awesome.
@hosainmirzade4317
@hosainmirzade4317 10 ай бұрын
very nice and deep thanks
@eedoan
@eedoan 10 ай бұрын
As a guy that like to develop games sometimes, these concepts are really cool to learn :). When I play a game with a really cool mechanic my developer brain always wonder how they did it. Hey, would be cool if you explain how Noita can do physics for essentially every pixel of the game without burning our computers.
@DigiDigger
@DigiDigger 10 ай бұрын
Good idea! That's actually something I want to dive into as well: putting it on the list :)
@Tinkerer_Red
@Tinkerer_Red 10 ай бұрын
You know Glen's "how it was made series"? It's essentially not actually teaching you how the mechanics work. This is where the hard efforts of DigiDigger comes in and truly teaches you the useful information.
@V4riousMind
@V4riousMind 10 ай бұрын
Wait what? oh yeah! Comeback Time
@6TheBACH
@6TheBACH 10 ай бұрын
If you are a videogame designer, or want to be one, this channel is one of the few that teach theory in a professional way without need to know much technical stuff. Other channels I suggest you are GameHut and Coding Secrets (same guy, but slightly different content).
@dukkhan1288
@dukkhan1288 10 ай бұрын
I was half expecting this to be a video about a clever use of the Command Pattern, but it never came up. I'm wondering if you considered it during your research but settled on the methods in the video?
@yagzsahin9321
@yagzsahin9321 10 ай бұрын
Amazing video! I have a question though. In the game timebenders, if players agreed to not kill eachother and just continue moving around, wouldn't saving all those frame information cause the game to crash or did you limit the amount of time players can rewind?
@unvergebeneid
@unvergebeneid 10 ай бұрын
The visualisation used in this video heavily implies a ring buffer. And most games with time reversal limit the time you can reverse.
@lj8549
@lj8549 10 ай бұрын
AKA Framerate Independence
@SOME_BORED_GUY
@SOME_BORED_GUY 10 ай бұрын
came in the right time been wondering about that since playing tears of the kingdom
@sebastienpautot
@sebastienpautot 10 ай бұрын
You can also guess the current velocity of the object by looking at its position and its position at the next frame, same thing for the rotation velocity. (not the previous one since you could've gotten a new force added at the current frame which impacted the next frame)
@kendakgifbancuher2047
@kendakgifbancuher2047 10 ай бұрын
That game of yours looks fun as hell
@Robbasd
@Robbasd 10 ай бұрын
PUMP UP THE JAM, PUMP IT UP WHILE YOUR FEET ARE STOMPIN
@a_grin_without_a_cat
@a_grin_without_a_cat 10 ай бұрын
Interesting thing about time rewinding in Sands of Time and other games from first ubisoft trilogy, is that it stores not frames, but fixed amount of animations. It is 12 or 20, I don't remember correctly. Current ANY% speedrunning strat is "zipping": quickly make more animations then this buffer can contain, and when, rewinding time, the player model will be launched with direction and velocity of the last animation, because the engine does not know what to do because there are no more animations to play. I guess it was made for performance reasons also: you don't need to store the entire timeline of all entities if all your moving entities are player and enemies, you just remember animation start frames and direction and then play animations in backwards.
@TheGreenkey
@TheGreenkey 10 ай бұрын
Great video! One suggestion from a non-native speaker though: please lower the volume of background music. It really distracts from your voice and makes understanding you way harder than it needs to be. Except for that, everything was really easy to understand!
@gagota336
@gagota336 10 ай бұрын
I wonder if you can improve performances by only storing key frames, like a change of direction ? Because if you think of it, you can always rewind a free fall path by only storing the end and the start of the path. It makes me want to make another game prototype that will never come into a real game...
@lovalmidas
@lovalmidas 9 ай бұрын
If you can let the engine figure everything out, the only key frames would be the initial state/environment, player inputs, and perhaps the RNG output. Trackmania kind of does this with their replay files.
@gagota336
@gagota336 9 ай бұрын
@@lovalmidas oh ok that's pretty crazy at this point ! Like you really need the engine to make the exact same operations every time
@imfaded3105
@imfaded3105 10 ай бұрын
Great explanation
@lucasc5622
@lucasc5622 10 ай бұрын
You haven’t seen the video yet
@ilieschamkar6767
@ilieschamkar6767 10 ай бұрын
13:50 So a span, very interesting To keep in mind!
@its_nuked
@its_nuked 3 ай бұрын
12:21 Could you make some kind of if statement and "isGoingInReverse" bool that you would negate when locally going backwards on each individual object, so that you'd only GLOBALLY record object movement if objects isGoingInReverse=false? Aka, to only record local movement in global movement if the local movement ISNT going in rerverse somehow? Great videos btw, I'm learning a lot here! Thank you ;D
@Tomyb15
@Tomyb15 10 ай бұрын
Conceptually, reversing time in classical mechanics is simply reversing the direction of every velocity. Couldn't then you reverse time in the game by recording all external events (like keypresses and every other interaction that isn't the direct result of the physics engine) and reversing all velocities (linear velocity, angular velocity, animations, etc)? You would then play the external events in reverse order at the appropiate time to essentially reenact the past. This could have problems with rounding errors and lead to divergences to what actually happened but I reckon they wouldn't be that big if the reversing is kept to a "small" duration. Basically, if you can get you physics engine to work deterministically, you could reverse time quite easily with little memory requirements. In fact, maybe both methods can be combined to make sure that the "reenacments" don't diverge too much by periodically (buy not too often) resetting the state of the objects to what the recorded state says it should be at that point in the rewind.
@lovalmidas
@lovalmidas 9 ай бұрын
More than the physics engine has to be deterministic. Games often involve destroying and creating objects, so you will need maintain a record from the past so you can 'reverse' their deletion. If there were random number generators used (and they don't usually work in the reverse direction), you need to work around it. You'll also need to reverse AI states, which might be complicated if you are using anything other than a history table. The super minimalistic idea would come in the form of a word document with undo function. The undo function itself contains memory of what was changed, and sometimes it is easier to keep one record of a 3MB image and have the undo function reference it, than have various undo steps keep a copy of it each time it is transformed.
@Tomyb15
@Tomyb15 9 ай бұрын
@@lovalmidas yes, all those external "interactions" to the physics engine would need to be recorded.
@aviinl1
@aviinl1 10 ай бұрын
you broke me at 4:55
@dmMeBikes
@dmMeBikes 10 ай бұрын
Christmas in July, what a pleasant surprise.
@ilieschamkar6767
@ilieschamkar6767 10 ай бұрын
Thanks Cunk!
@voxelliptic6592
@voxelliptic6592 9 ай бұрын
How do you produce your videos and make visual representations?
@memk
@memk 10 ай бұрын
Do you know about Achron? The RTS game that you can time travel in multiplayer
@manualdomundo2550
@manualdomundo2550 10 ай бұрын
Sooo, if i had 2 different variables for a delta time, could an object move at a different velocity from the world? Like, lets day we freeze the worlds delta time, but the player still has the normal delta time, would the player still br able to move while the world is stopped? If so, could we have something like the Flashs perspective? If we make the worlds delta time really slow, and the player moves, we record it but play the recording speeding the worlds delta time and the players so the ratio is still the same but the worlds delta time is the same as the original ome from the player, would the player move super fast, while retaimimg their own sense of time? Honestly i have so many questions now, and i could even list some more that i thought off, but it would be boring to everyone lol Ps: sorry for bad english, not my native language
@lovalmidas
@lovalmidas 9 ай бұрын
Typically, you would store one additional deltaTime for a local override, and a boolean switch to indicate whether the object should use its own local deltaTime. This recreates the Bullet Time and the SuperHot core mechanics, where the player moves with his own deltaTime (kept fairly constant to not disorient the player), while the rest of the world moves with the global deltaTime (tied to the player's movement for SuperHot). In the world's perspective, it will seem like the player is moving really fast, assuming the engine is able to handle the speedup and still make accurate physics calculations.
@chris.dillon
@chris.dillon 9 ай бұрын
I did the smashmouth tabs thing and I need a doctor.
@TheK0tYaRa
@TheK0tYaRa 10 ай бұрын
Knowledge.
@Kenionatus
@Kenionatus 10 ай бұрын
TheStellarJay would have probably really liked that game if it ever got released.
@Kenionatus
@Kenionatus 10 ай бұрын
It's ironic that the podcast plug has a bad audio quality filter over it.
@omarelric
@omarelric 7 ай бұрын
Time and space are productions of the mind imposed on reality to structure it.
@kainan613
@kainan613 10 ай бұрын
WHOOOOOO LET'S GOO
@xiaoyi28
@xiaoyi28 10 ай бұрын
Dissapointed at the lack of foldyflaps and moonman.
@kitastro
@kitastro 10 ай бұрын
Hehe I've also used this method before
@andreas.soderlund
@andreas.soderlund 10 ай бұрын
"How would it rate the current state of the west capitalist market economy" was the most hopeful thing I've heard in quite a while...!
@morgan0
@morgan0 10 ай бұрын
5:05 lmao
@AnthonyMiele
@AnthonyMiele 10 ай бұрын
Return of The KIIIINNNGGGG
@lucasc5622
@lucasc5622 10 ай бұрын
Cringe
@nicks4727
@nicks4727 10 ай бұрын
Time.timeScale = 0.5f;
@utoherozv
@utoherozv 10 ай бұрын
Wait other people know about Quantum League? WAIT WAIT WAI-
@moth.monster
@moth.monster 10 ай бұрын
I wonder how ToTK's Recall ability works. It's incredibly janky and a bit overpowered, but still very fun. Of course, it only acts on one object at a time, but you can run it on just about any physics object...
@NicolasEmbleton
@NicolasEmbleton 10 ай бұрын
You actually called it. It's linked to physics. Probably storing every physics frame locally in a memory efficient way (I'd assume a local, maxed local buffer of sorts). The hard part here likely being that there are so many scenes that you want to make sure the object graph tree is superbly managed or it'll end up glitching hard.
How does ray tracing produce hyper realistic graphics? | Bitwise
18:27
ПЕЙ МОЛОКО КАК ФОКУСНИК
00:37
Masomka
Рет қаралды 10 МЛН
Bro be careful where you drop the ball  #learnfromkhaby  #comedy
00:19
Khaby. Lame
Рет қаралды 43 МЛН
Half-Life 1 | Game Plunge
21:15
DigiDigger
Рет қаралды 13 М.
How do games render their scenes? | Bitwise
13:12
DigiDigger
Рет қаралды 561 М.
How the walls in The Sims are lying to you | Bitwise
10:15
DigiDigger
Рет қаралды 13 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 334 М.
Gamings Most ADDICTIVE Movement Mechanic
10:14
Creem
Рет қаралды 1,5 МЛН
Adding Extreme Time Control to my Game
9:03
AAlex
Рет қаралды 31 М.
Valve's "Secret Weapon"
17:32
Game Maker's Toolkit
Рет қаралды 1,4 МЛН
Timeshift is a completely original Bullet Time 2000s FPS
8:05
oboeshoesgames
Рет қаралды 248 М.
10 Unforgettably BADASS Video Game Abilities
12:56
gameranx
Рет қаралды 3,3 МЛН
Escape Nextbots Rosalia And Obunga Police #gmod
0:36
BizarroTube GMod
Рет қаралды 17 МЛН
Minecraft RTX 203% CLUCK KENT #Shorts
0:29
Jake Fellman
Рет қаралды 19 МЛН
Here comes Baby Peach
0:14
Troopa Deluxe
Рет қаралды 14 МЛН