TIME REWIND mechanic for every objects in Godot!

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • Ігри

КОМЕНТАРІ • 31

  • @mrelipteach
    @mrelipteach  2 роки тому +3

    I hope you liked this tutorial! If you want to see it in action, checkout my latest Dashpong devlog: ua-cam.com/video/6senbbMsi8M/v-deo.html

  • @kevinbreen4510
    @kevinbreen4510 2 роки тому +1

    Thanks for sharing! Looking forward to giving this a try in the future.

  • @DayMoniakkEdits
    @DayMoniakkEdits Рік тому +10

    If you're using Godot 4 "Engine.iterations_per_second" is now "Engine.physics_ticks_per_second"

  • @_gamma.
    @_gamma. 2 роки тому +5

    Nice tutorial! I can also see how it would be useful with 4.0’s movie feature for recording replays, like Towerfall

    • @mrelipteach
      @mrelipteach  2 роки тому

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

  • @hassangolshan3295
    @hassangolshan3295 10 місяців тому +2

    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  10 місяців тому +2

      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.

    • @this-cris
      @this-cris 9 місяців тому

      I appreciate that you are responding to comments a year after the video was posted. I had the same question while watching.

  • @kotarou8530
    @kotarou8530 Рік тому

    thank you, helped me a lot :)

  • @GoggleMan1
    @GoggleMan1 3 місяці тому +1

    where is the code? 😭😭😭😭

    • @mrelipteach
      @mrelipteach  3 місяці тому +1

      In the 3.x branch on Github
      github.com/MrEliptik/godot_experiments/tree/3.x/2D/rewind_mechanic

    • @GoggleMan1
      @GoggleMan1 3 місяці тому +1

      @@mrelipteach thank you

  • @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.

  • @mikielek8657
    @mikielek8657 2 роки тому

    This was wonderful !! I will try it
    Also u had a really nice and fluent presentation style, keep it up!

    • @mrelipteach
      @mrelipteach  2 роки тому

      Glad you found it useful! Thanks a lot :)

  • @christiankoch9516
    @christiankoch9516 2 роки тому

    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  2 роки тому +1

      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 2 роки тому

      @@mrelipteach Thanks for the reply, I will have a look once I get home from work, but it looks promising

  • @chaoscifer1483
    @chaoscifer1483 2 роки тому

    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  2 роки тому +1

      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 2 роки тому

      @@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  2 роки тому +1

      @@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 Рік тому

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

  • @SnakeEngine
    @SnakeEngine Рік тому

    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  Рік тому

      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 2 роки тому

    Engine.rewind(0.5,0,0)