TIME REWIND mechanic for every objects in Godot!

  Рет қаралды 6,492

MrElipteach

Жыл бұрын

I show you how to create a time rewind mechanic with Godot, working for whatever object type! Such a mechanic is seen in Prince of Persia, Braid or my own game Dashpong!
🎓 Learn how to make JUICY games 👇
www.udemy.com/course/learn-how-to-make-a-game-juicy-in-godot-4/?referralCode=1652C74B848551E05DAE
See the mechanic in action in my latest Dashpong devlog
👉kzbin.info/www/bejne/bKTIn5WYgticbq8
🔗 Sources github.com/MrEliptik/godot_experiments
🔗 Player input method: kzbin.info/www/bejne/d5nSaauLg7yoopo
🎮 GAMES
~~~~~~~~~~~~
🎮 Prince of Persia: Sand of time
🎮 Braid
🎮 Dashpong: s.team/a/1729250/
🎶 MUSIC
~~~~~~~~~~~~
🎵 HolzinaRAPS - Pastries behind the glass
🎵 Ketsa - Bring the swing
👤 SOCIALS
~~~~~~~~~~~~
💰 One time donation: ko-fi.com/mreliptik
💰 Support me on Patreon: patreon.com/MrEliptik
🟣 Join us on Discord: discord.gg/83nFRPTP6t
🔴 Twitch: twitch.tv/mreliptik
🐤 Twitter: mreliptik
🎥 TikTok: www.tiktok.com/@mreliptik
🖼️ Instagram: mreliptik
🔗All links: bento.me/mreliptik
🔖 CHAPTERS
~~~~~~~~~~~~
00:00 - What we are going to do
00:36 - Other method
00:47 - My approach
01:13 - KinematicBody2D
03:45 - KinematicBody2D demo
04:06 - RigidBody2D
05:24 - Final demo
05:32 - Godot course discount!
05:43 - Outro👉

Пікірлер: 31
@mrelipteach
@mrelipteach Жыл бұрын
I hope you liked this tutorial! If you want to see it in action, checkout my latest Dashpong devlog: kzbin.info/www/bejne/bKTIn5WYgticbq8
@kevinbreen4510
@kevinbreen4510 Жыл бұрын
Thanks for sharing! Looking forward to giving this a try in the future.
@DayMoniakkEdits
@DayMoniakkEdits Жыл бұрын
If you're using Godot 4 "Engine.iterations_per_second" is now "Engine.physics_ticks_per_second"
@ZNTHX
@ZNTHX 10 ай бұрын
Thanks bro
@maurizio9810
@maurizio9810 2 ай бұрын
my man
@_gamma.
@_gamma. Жыл бұрын
Nice tutorial! I can also see how it would be useful with 4.0’s movie feature for recording replays, like Towerfall
@mrelipteach
@mrelipteach Жыл бұрын
Yeah it could be a good solution to do offline replays saved as videos. I've tried to capture the viewport every frame to do video replay but unfortunately it's too slow for now, and it affects performance while in game...
@mikielek8657
@mikielek8657 Жыл бұрын
This was wonderful !! I will try it Also u had a really nice and fluent presentation style, keep it up!
@mrelipteach
@mrelipteach Жыл бұрын
Glad you found it useful! Thanks a lot :)
@kotarou8530
@kotarou8530 Жыл бұрын
thank you, helped me a lot :)
@mrelipteach
@mrelipteach Жыл бұрын
Glad to hear that!
@hassangolshan3295
@hassangolshan3295 7 ай бұрын
Hi, thanks for your tutorial. How do you think runtime-instantiated objects should get handled in time rewind? Same problem for runtime-destroyed objects. In your sample demo, all the objects are in the scene from the beginning to the end. What if there are many objects being instantiated/destroyed during the game (like bullets, particles, and so on)?
@mrelipteach
@mrelipteach 7 ай бұрын
I do exactly that in my game Dashpong as paddle are created by the players and destroyed after some time. These objects save their positon and rotation just like the others. To know when to create/destroy them during rewind/replay, you need to compare to a reference. For that, I save values in a global script and when it's time to rewind/replay, I compare the object's value count to this global count. If the object has less values, it means it has to be destroyed/created. To know if it's created or destroyed, I save a boolean for the fame of creation/destruction. You can probably find other ways to do it, like having a unique frame ID that is available globally so you can easily compare when objects are created/destroyed.
@thiscris-qj7ce
@thiscris-qj7ce 6 ай бұрын
I appreciate that you are responding to comments a year after the video was posted. I had the same question while watching.
@christiankoch9516
@christiankoch9516 Жыл бұрын
Hello, I did something similar in Unity some time ago, but when trying to rewind Animations in Unity I realised that the Animator component of unity was not fit for this kind of implementation. I was wondering if you know if the Animation components of Godot are a bit more cooperative in resepect to rewinding animations (3D), particularly repeated rewinding while recording new data between rewinds. Unitys Animator simply deletes the old animator states once new data is stored
@mrelipteach
@mrelipteach Жыл бұрын
I don't know if this is exactly what you want but you can play any animation backwards using play_backwards() docs.godotengine.org/en/stable/classes/class_animationplayer.html#class-animationplayer-method-play-backwards
@christiankoch9516
@christiankoch9516 Жыл бұрын
@@mrelipteach Thanks for the reply, I will have a look once I get home from work, but it looks promising
@chaoscifer1483
@chaoscifer1483 Жыл бұрын
Very nice approach. Thank you. I think that we could have some issues if we use the same replay files across in different machines, since Godot's physics is not deterministic.
@mrelipteach
@mrelipteach Жыл бұрын
How would that be a problem? The idea with this technique is that you save all the values and move every object manually, deactivating physics and thus not being affected by the non determinisc nature of Godot's physics
@chaoscifer1483
@chaoscifer1483 Жыл бұрын
@@mrelipteach I believe (not affirming) that without a fixed point math for the amount that we're moving objects we'll have a high probability of generate slightly different floats in different hardwares and operational systems. edit here: I think that the probability is even bigger when we multiply floats and use deltatime within _process()
@mrelipteach
@mrelipteach Жыл бұрын
@@chaoscifer1483 It's possible yes but if you care about having exactly the same result, you should use fixed point. Most people won't care about that, because the potential difference is ultra tiny
@SnakeEngine
@SnakeEngine 9 ай бұрын
@@mrelipteach The difference can be life or death. The bullet either hits you or not in an edge case. I think you don't understand what an instable system is.
@ro-ce8vg
@ro-ce8vg Жыл бұрын
I am new to Godot, but are you not preallocating the array of positions/vel/rotations? I would think that for multiple physics objects, preallocating the array could have serious performance implications. edit: realized that you still only have to allocate the array once regardless, so maybe not as important. i guess if i was concerned about performance, this would be a good place to use GDNative
@mrelipteach
@mrelipteach Жыл бұрын
You should optimize only if there's a need for it. In this case, I didn't see any performance hit.
@GoggleMan1
@GoggleMan1 4 күн бұрын
where is the code? 😭😭😭😭
@mrelipteach
@mrelipteach 2 күн бұрын
In the 3.x branch on Github github.com/MrEliptik/godot_experiments/tree/3.x/2D/rewind_mechanic
@GoggleMan1
@GoggleMan1 Күн бұрын
@@mrelipteach thank you
@SnakeEngine
@SnakeEngine 9 ай бұрын
Yeah that's the easy part everyone knows about since you assume a static life-time of objects. But how would you handle a time rewind in a dynamic scene where objects get created and destroyed?
@mrelipteach
@mrelipteach 9 ай бұрын
It's a 6 mins tutorial, I can't go into great details. I've done a more complex implementation in my game Dashpong because it has to support dynamically created objects (paddles). The idea is to have something to comapre to, so I added a global rewind counter. Then it's about comparing the amount of values a paddle has in its rewind array and you know it needs to be created or deleted.
@vikramthewrench
@vikramthewrench Жыл бұрын
Engine.rewind(0.5,0,0)
@mrelipteach
@mrelipteach Жыл бұрын
That would be nice!