REWIND TIME in Unity

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 809

  • @nekit8742
    @nekit8742 4 роки тому +451

    Everyone participating in Brackeys Game Jam 2020: OH YES, REWIND TIME

  • @Brackeys
    @Brackeys  7 років тому +227

    To those of you who want to make this code more performant here are a few things to keep in mind:
    - Because we are only storing simple values, consider using a struct instead of a class.
    - Because we are "overwriting" values consider using an array with a fixed length and then simply swapping in/out values when we reach the end of the array.
    Using generic lists is handy but will always be slower than an array with a given size.
    Also to those of you who suggest using a Stack. This makes perfect sense and was actually what I started by using. However we do need the ability to overwrite values and therefore we need to access items at the bottom of the list which a stack by definition won't do. Please do let me know if there is any way to make this code run faster using a stack vs. an array :)
    Hope you guys like the video! :)

    • @selvexfu
      @selvexfu 7 років тому +23

      I posted this as a comment already, but I will paste it here since you seem to be interested in it.
      Performance tweek: as some already mentioned lists are not optimized for this usecase (intel focuses on lists so it's still lightning fast, but there are better solutions)
      The thing that fits this purpose perfectly would be a LinkedList. It provides you with removeLast() and addFirst() out of the box and is sickengly optimized for manipulating the start and the end of the list.
      Love your videos. Thanks.

    • @TheMasterpikaReturn
      @TheMasterpikaReturn 7 років тому +2

      are C# lists actually ArrayLists? because when i see "list" i immediately think about LinkedList, which should be quite good for this case (because prepending is O(1), iirc). I guess using an Array would work too, but it feels more awkward to me(if we insert stuff at the start)

    • @iammichaeldavis
      @iammichaeldavis 7 років тому +13

      Also adding to the end of the lists instead of inserting into the front is way more efficient: stackoverflow.com/questions/18587267/does-list-insert-have-any-performance-penalty
      Thanks so much for this technique. Love your videos!

    • @darkhummy
      @darkhummy 7 років тому +14

      Could also only record every 2 or more fixedtimestep steps and lerp between each point if you really needed optimization.

    • @georgy028
      @georgy028 7 років тому +15

      The best performance would be if you use a fixed length circular array (also called circular buffer) so you do not have to rearrange values just change the pointers (start and end) whenever you add or remove values

  • @etaxi341
    @etaxi341 7 років тому +498

    you shuld store the rigidbody velocity too so it flys in the same direction again after the rewind

    • @t.wood01
      @t.wood01 7 років тому +18

      Great idea! I was just getting ready to ask about how to make the objects continue flying after the rewind.

    • @1234macro
      @1234macro 7 років тому +3

      You would only need to store this once, and change it after each new point.

    • @viktorkrasovskyi7837
      @viktorkrasovskyi7837 7 років тому +29

      don't forget about angular velocity too ;)

    • @jacobmakob1
      @jacobmakob1 7 років тому +37

      I've gone with:
      above the TimeBody class
      public struct PointInTime
      {
      public readonly Vector3 position;
      public readonly Quaternion rotation;
      public readonly Vector3 velocity;
      public readonly Vector3 angularVelocity;
      public PointInTime(Transform t, Vector3 v, Vector3 aV)
      {
      position = t.position;
      rotation = t.rotation;
      velocity = v;
      angularVelocity = aV;
      }
      }

    • @jacobmakob1
      @jacobmakob1 7 років тому +26

      Then I run this at the end of StopRewind:
      void ReapplyForces() {
      rb.position = pointsInTime[0].position;
      rb.rotation = pointsInTime[0].rotation;
      rb.velocity = pointsInTime[0].velocity;
      rb.angularVelocity = pointsInTime[0].angularVelocity;
      }

  • @RumbleKnightYT
    @RumbleKnightYT 4 роки тому +185

    Brackeys: Makes a game jam with the topic rewind
    Me: (uses their own tutorial on it)
    *STONKS*

  • @vectozavr
    @vectozavr 4 роки тому +37

    In PointInTime class you can add information about velocity and angular momentum to set the same velocity as it was at each particular moment (to get rid of the problem when cube after rewinding just falling down)

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

      This would be a fantastic addition to this.

    • @TheIronicRaven
      @TheIronicRaven 3 роки тому

      How does one add the velocity and angular momentum? I mean what are the parameters? Just rigidbody.velocity? And rigidbody.angle?

    • @silent1um706
      @silent1um706 3 роки тому

      Sometimes my boxes still falling down after rewind ( what could cause this problem?

    • @TheIronicRaven
      @TheIronicRaven 3 роки тому

      @@silent1um706 is your gravity still on? On the rigidity. That would cause it fall when you are done rewinding

    • @atlasua2021
      @atlasua2021 3 роки тому +1

      Привет) ты бы мог сделать игру с регрессией времени) было бы любопытно.

  • @epicbladeunity4285
    @epicbladeunity4285 4 роки тому +148

    Who is here for the Brackeys Jam Theme : Rewind and getting help like i am!!

    • @GwydionV
      @GwydionV 4 роки тому +3

      Gotta use what resources you have access to

    • @mithunmmurthy1473
      @mithunmmurthy1473 4 роки тому +3

      I thought I am first from the game jam 😂😂

    • @epicbladeunity4285
      @epicbladeunity4285 4 роки тому

      @@GwydionV trueeee

    • @RumbleKnightYT
      @RumbleKnightYT 4 роки тому +5

      Brackeys: Makes a game jam with the topic rewind
      Me: (uses their own tutorial on it)
      *STONKS*

    • @alejandrohaynes81
      @alejandrohaynes81 4 роки тому

      i'm 14 and this is deep, they literally made the theme about a brackeys video that already exists

  • @RitobanRoyChowdhury
    @RitobanRoyChowdhury 7 років тому +278

    One thing I'd like to point out is that when Brackey's mentions that with 50 cubes, you're already storing 2,500 values, its not actually that much.
    Each point in time is a Vector3 and a Quaternion. The Vector3 is 3 floats, the Quaternion is 4. Each float is 4 bytes.
    That means each point in time is (3+4)*4=28 bytes. Unity can easily handle tens of thousands of 28 byte classes.
    If we take the scenario here, we have 50 cubes and we are recording 50 times per second. In one second:
    50*50*28 = 70,000 bytes
    70,000 bytes = ~68 kilobytes.
    In comparison, a 512x512 png image is 1027 kilobytes.
    In this scenario, you're loading in a small png sprite every ~15 seconds. That's nothing, even on a mobile device. You probably aren't ever going to rewind longer than 10 seconds, so you're not even loading a full png image into RAM ever.

    • @davidkoffi985
      @davidkoffi985 7 років тому +5

      Ritoban Roy Chowdhury SMART

    • @Laflamablanca969
      @Laflamablanca969 7 років тому +36

      Ritoban Roy Chowdhury yeh the storing of the values isn't much space but having 50 objects that have a script on them with both update and fixed update is unnecessary. It's a good video for beginners to understand the concept but I certainly wouldn't implement it this way.

    • @ItsGlizda
      @ItsGlizda 7 років тому +2

      What would you do instead? Store all the data inside one manager script?

    • @davidkoffi985
      @davidkoffi985 7 років тому

      La Flama Blanca there isn't another way to do it. that would be better necessarily

    • @RitobanRoyChowdhury
      @RitobanRoyChowdhury 7 років тому +20

      I would store all the data inside a manager script. Unity can easily manage tens of thousands of simple game objects with renderers (see: quill18creates Project Porcupine Episodes 1-3). However MonoBehaviours have quite a large overhead (moreso when compared to just a GameObject or Transform Reference), making is significantly less memory.

  • @zannleft7117
    @zannleft7117 7 років тому +53

    I'm dead fucking serious I searched for this yesterday and nothing came up. Thank you sooo much for reading my mind

    • @prototypeinheritance515
      @prototypeinheritance515 6 років тому

      there is a wonderful talk by jonathan blow on his game braid and his implementation of a rewind mechanic. He recorded up to a half hour of game

  • @makra2077
    @makra2077 4 роки тому +79

    Brackeys game jam 4 goes brrrrrrr

  • @VperVendetta1992
    @VperVendetta1992 7 років тому +1

    I was looking for a tutorial like this for years. The presentation from the Braid videogame developer was the only thing I could find, but this is way better and more detailed. Thank you so much.

  • @KelvinCipta
    @KelvinCipta 4 роки тому +18

    Brackeys theme : rewind
    Me : ok, let's watch this again

  • @timmyward349
    @timmyward349 4 роки тому

    This is a GREAT mechanic for a video game. In fact, I know a few video games that do this.

  • @caedriel5555
    @caedriel5555 6 років тому

    Seeing this reminded me of a project we did initially in our degrees where we did the same thing however we saved X amount of vector 3 positions to demonstrate our understanding of lists & stacks

  • @maxofcourse
    @maxofcourse 7 років тому +3

    Couldn't wait for this video to come out after it was leaked a while ago

  • @adityansah
    @adityansah 4 роки тому +16

    Here during Brackeys Jam 2020.2

    • @se9979
      @se9979 4 роки тому +1

      well... The program doesnt work for me, did it work for you?

    • @kidjuke6262
      @kidjuke6262 4 роки тому

      Any got ideas to spare for the game jam

  • @benjohnson7610
    @benjohnson7610 7 років тому

    Very nice and simple tutorial, I can see a lot of new developers making great use of this. One tip for anyone who wants the replay to continue as normal, be sure to save the current velocity of the rigidbodies as well as their positions and rotations. This way when you finish your rewind the explosions will still happen as expected. You may also need to keep track of more advanced things like timed events that you trigger at certain times such as sphere casting for a grenade explosion, or variables that could be effected. For advanced objects you will probably want to make a subclass of the basic script that records this extra data.

  • @Lucavon
    @Lucavon 4 роки тому

    I did this yesterday. Now I found this tutorial. Turns out our ideas were exactly the same, I implemented it the exact same way (except for not setting the Rigidbodies kinematic, and just disabling their gravity instead). I also added interpolation for high-refresh-rate monitors, but other than that, it's the same!

  • @domizzp.2785
    @domizzp.2785 7 років тому +63

    Suggestion for future tutorials: before the tutorial do a quick showcase of how you are going to achieve the effect. For example here before you start programming just say we are going to rewind time by storing the positions and rotations of each object at some time rate and then setting them back... You get the idea :D. Some people are just interested in HOW to do something and they can do the programming part themselves :)

  • @abdelhaksaouli8802
    @abdelhaksaouli8802 4 роки тому +34

    i wonder how many view this video will get after the 2020 summer jam ends x')

  • @dorotikdaniel
    @dorotikdaniel 7 років тому +35

    Very nice tutorial. Just make sure not to use List in this case, since Insert needs to shift all elements internally [O(N)], while Add does not [O(1)]. For example, when I ran insertion of 100000 items into List, it took 2.1sec, while addition took 0.003sec! Easiest would be to use LinkedList, where both insertion and removal are O(1) operations. Cheers!

    • @vinidotnet
      @vinidotnet 7 років тому

      Thanks for pointing this out. In the end performance matters and using Queue or LinkedList could make this code a lot more efficient.

    • @pfarnach
      @pfarnach 7 років тому

      I don't doubt your research, and I'm new to C# myself, but some quick googling says that Linked Lists in C# are usually slower than Lists, except, sometimes, in the case of random insertions.
      stackoverflow.com/questions/5983059/why-is-a-linkedlist-generally-slower-than-a-list

    • @vinidotnet
      @vinidotnet 7 років тому +7

      In our specific case we just need 2 major operations in our list to make rewind works.
      1. To make sure we record only 5 seconds we constantly need to remove the last item of the list. Both LinkedLists and Lists will have the same performance in this operation (maybe Lists are a little faster since LinkedLists also need to deal with memory management, but to be honest it's not too relevant).
      2. We have to constantly record the movement and INSERT it at the BEGINNING of the list. Here's when Lists become expensive. Every time you insert at the beginning of the List it will shift every other item to adjust indexes.
      You basically saying "Hey List, put this guy at the beginning (first position number 0)" then the List will answer "Okay, but since we already have someone at this position we first need to move him to the next room and do this to every guy after him".
      The same applies when we turn on our rewind. We will be removing items from beginning and the List will need to adjust indexes again.
      This is when LinkedLists become useful. It does not have indexes, so if we need to insert at the beginning of the list it will simple create it in memory and will link it to the next item that was previously our first element.
      The point is: Inserting at the end both are similar but since we need to CONSTANTLY insert items at the beginning of our array, List will CONSTANTLY shift ALL items to adjust indexes. Imagine every frame we having to move every item in the list. Meanwhile with LinkedLists we will worry only with adding and removing.
      See this answer in the same topic that you shared: stackoverflow.com/a/5983207.
      My English isn't that good, sorry in advance. Hope this explains your question. If you want to lean more you can search "doubly linked lists data structure" and "big-o notation".

    • @jymmy097
      @jymmy097 7 років тому +2

      ...Or if you wanted to have a more abstracted representation, I'd have used a Stack.

    • @vinidotnet
      @vinidotnet 7 років тому +1

      Stack won't work properly since we need to remove from the bottom of our list constantly to hold only 5 seconds of data. Stack is LIFO (last in, first out) which means that it can only remove data from the top of the list.

  • @pedroprass106
    @pedroprass106 4 роки тому +17

    Imagine if Brackeys Jam had the rewind theme just so he could increase the view count in this video e.e

    • @youssefkassem4895
      @youssefkassem4895 4 роки тому

      have you got a game idea? for the jam

    • @David-vz4yk
      @David-vz4yk 4 роки тому

      Youssef Kassem I know a friend on yt called Part-time toaster, he really smart and makes devlog, he Will probably make a devlog out of the jam

  • @Rawbful
    @Rawbful 6 років тому

    So weird you have a video on this. I was just thinking about how Braid might have done what they did with time rewinding and this understanding certainly helps!

  • @MrKraignos
    @MrKraignos 7 років тому

    A tip if you want to edit your private fields in the inspector without making them public, you should use the tag [SerializeField]. Making a field public *only to see it in Unity* is a shame that breaks the encapsulation offered by POO, and could lead to chaos later if your project becomes bigger. Have a nice day.

  • @vandameh.a2235
    @vandameh.a2235 4 роки тому +2

    I am studying video game programming and your videos are my inspiration to not stop chasing my dream.
    A M A Z I N G
    BTW: I have completed succesfully your tutorials of tower defense and rpg!! Thanks you very much

  • @odmehbb
    @odmehbb 4 роки тому

    First of all, I love your videos, thanks for all the stuff I've learned. You should consider using a Stack instead of a List. That structure is exactly for this kind of approach. Also, if you stop rewinding in the middle, and record additional positions, you will still be able to rewind to the beginning afterwards.

  • @BillyMan
    @BillyMan 4 роки тому +21

    Anyone watching this cuz of Brackeys Jam 2020.2 :) ?

    • @CreatePlayGames
      @CreatePlayGames 4 роки тому

      Do we need to use unity3d 2020.2 version for this?

    • @CreatePlayGames
      @CreatePlayGames 4 роки тому

      BTW im planning to join this game jam thats why im asking :)

  • @sajrapraveen4963
    @sajrapraveen4963 4 роки тому +12

    Hey I am from Future,
    I came here to tell you that your tutorial will help in your forth game jam themed Reverse
    Thank you

    • @CreatePlayGames
      @CreatePlayGames 4 роки тому

      hi, future, when is the deadline for this?

    • @sajrapraveen4963
      @sajrapraveen4963 4 роки тому +1

      @@CreatePlayGames 8 August 3:30 PM according to Indian Standred Time

    • @CreatePlayGames
      @CreatePlayGames 4 роки тому

      @@sajrapraveen4963 tnx, hows ur progress?

  • @RugbugRedfern
    @RugbugRedfern 7 років тому +7

    To keep the velocity of the cube:
    (This is from another one of my posts)
    *In the PointInTime class:*
    public Vector3 position;
    public Quaternion rotation;
    public Vector3 velocity;
    public Vector3 angularVelocity;
    public PointInTime(Vector3 _position, Quaternion _rotation, Vector3 _velocity, Vector3 _angularVelocity) {
    position = _position;
    rotation = _rotation;
    velocity = _velocity;
    angularVelocity = _angularVelocity;
    }
    *Then in StopRewind() just add the code*
    GetComponent().velocity = pointsInTime[0].velocity;
    GetComponent().angularVelocity = pointsInTime[0].angularVelocity;
    *Just make sure the last pointInTime isn't deleted*
    *I just did this*
    if(pointsInTime.Count > 1) {
    PointInTime pointInTime = pointsInTime[0];
    transform.position = pointInTime.position;
    transform.rotation = pointInTime.rotation;
    pointsInTime.RemoveAt(0);
    } else {
    PointInTime pointInTime = pointsInTime[0];
    transform.position = pointInTime.position;
    transform.rotation = pointInTime.rotation;
    }
    *Also gives the nice effect of when you've completed rewinding, it just freezes time until you let go of the return key.*

    • @rodrigobronselli59
      @rodrigobronselli59 7 років тому +1

      What about animations? Can I implement this on characters too?

    • @RugbugRedfern
      @RugbugRedfern 7 років тому

      I'm not sure... There might be a way.

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

      Hello, i do what u wrote but its not working ;// . pointsInTime.Insert(0, new PointInTime(transform.position, transform.rotation) ); i Have problem here, please help!

  • @gregorymccardle4004
    @gregorymccardle4004 6 років тому +27

    When you said C sharp I just though of instruments and my instrument and I almost snapped into position....

  • @MaeveFirstborn
    @MaeveFirstborn 7 років тому

    To add on to this, I'd add a curve value that allows it to slow down to a halt, and then move slowly back, but at the value of the curve, ie, moving back faster the longer it's being done.

  • @SuperRalle123
    @SuperRalle123 7 років тому +2

    Really well made video, thanks for the hard work; It makes it all the more worth being a patreon.
    I would love to see a tutorial like this on how animations work, it could possibly fit together with your blender series!

    • @CamperGuy
      @CamperGuy 7 років тому +1

      Rasmus Tollund I would love to see this video. Nice to see other patreons as well ^.^

  • @Dasheon
    @Dasheon 4 роки тому +156

    We all know why you're here

    • @GavinBot
      @GavinBot 4 роки тому +5

      Game jam lol

    • @David-vz4yk
      @David-vz4yk 4 роки тому

      ItsMeDash2 agreed

    • @TheLoveMiku
      @TheLoveMiku 4 роки тому

      Can someone please tell me if the empty Game object named Cubes has some components to it?

    • @nullreferenceexception1448
      @nullreferenceexception1448 4 роки тому +9

      I'm actually here cause I find it interesting. The coding seems easy but i'm too lazy to do anything in Unity.. Or even install Unity.

    • @Sylfa
      @Sylfa 4 роки тому

      More like, UA-cam is now recommending this cause of all you lot going here to watch it for the gamejam...

  • @charlie2915
    @charlie2915 4 роки тому +30

    Me when GameJam

  • @blekcode1416
    @blekcode1416 4 роки тому +3

    Lmao, now everybody will be here cause of the jam :D

  • @JuniorDjjrMixMods
    @JuniorDjjrMixMods 4 роки тому +1

    In addition to the low performance due to the use of List.Insert(0,*), your solution is dependent on FPS to work correctly.

  • @selvexfu
    @selvexfu 7 років тому +1

    Performance tweek: as some already mentioned lists are not optimized for this usecase (intel focuses on lists so it's still lightning fast, but there are better solutions)
    The thing that fits this purpose perfectly would be a LinkedList. It provides you with removeLast() and addFirst() out of the box and is sickengly optimized for manipulating the start and the end of the list.
    Love your videos. Thanks.

  • @ninojanjeremygo463
    @ninojanjeremygo463 7 років тому +4

    Wow, when I saw that rewind uoısoןdxǝ, what's in my mind it's like a, sort of, Prince of Persia game!

  • @toastape5298
    @toastape5298 7 років тому +1

    @Brackeys - Also have to record physics' velocities (both positional and rotational) and add them back to the objects after disabling kinematics flag, so that objects obey inertia after going out of the rewind (unless that sudden "stop in midair" at 13:10 is intended behavior =P).
    Other than that, perfect tutorial! =)

  • @neverknowsbezt
    @neverknowsbezt 7 років тому +1

    Maybe you could store position and rotation every 0.1 sec, then use translate to move object to that position. You save lot of intermediate positions and rotations. Also, as etaxi341 said, you could store the rigidbody velocity so it keeps moving in the same direction when you release the rewind button.

  • @cbox_
    @cbox_ 7 років тому +1

    Long time viewer Brackeys, love your vids. You explain things so perfectly. Definitely the best out there.

  • @fachri17
    @fachri17 4 роки тому +10

    came here for the jam

  • @NatorVlol
    @NatorVlol 4 роки тому +1

    Perfect! Now I’ll know how to rewind in the game Jam!

  • @imperialdynamics5346
    @imperialdynamics5346 6 років тому

    another excellent video from Brackeys. I don't understand why some people downvoted again! (oh well, internet)

  • @NavedAhmadX
    @NavedAhmadX 5 років тому

    I'm learning unity engine and your channel is helping a lot. Also. Blackthornprod's channel is very helpful as well

  • @Lobobobo123
    @Lobobobo123 4 роки тому +11

    Hi, fellow Game Jammer :)

  • @mpattym
    @mpattym 6 років тому +1

    Very cool video, i personally don't use unity (i prefer ue4) but the logic you went through was well explained and can be applied to any game engine.
    For those that are using physics objects you may also want to track the objects velocity. This way objects will continue along there path instead of just dropping when you stop rewinding time.

  • @Treyzania
    @Treyzania 7 років тому +1

    I believe that PointInTime should be a struct, not a class. That way it can be copied around and you won't have to worry about load from GCing them later.

  • @muhseng9838
    @muhseng9838 4 роки тому +100

    anyone here from the brackeys 2020 game jam ?

  • @TomtheMagician21
    @TomtheMagician21 3 роки тому

    The way he explains why he does everything is so helpful and especially since it doesn't slow the video down so it'd fast but still followable

  • @kylestankovich2199
    @kylestankovich2199 7 років тому

    The *PointInTime* class should be a struct. I totally would have used it as a class too, but I just realized that a struct is a perfect fit for that.

  • @andre.drezus
    @andre.drezus 7 років тому

    Nice, now I can finally get a headstart in my Clock Blockers based game

  • @In-N-Out333
    @In-N-Out333 4 роки тому +1

    I haven't tried this, but in C#7, you can use tuples to create a list that holds both positions and rotations. So it may not be necessary to create a class to hold those two data types.

  • @michu4381
    @michu4381 4 роки тому

    You should've store the latest position as the last element of the list. Add(...) has amortized O(1) time complexity, while Insert(0, ...) has O(n). It might have an impact on performance if you store a lot of positions for a lot of objects.

  • @ChooseKindness9999
    @ChooseKindness9999 4 роки тому +3

    Haha I know why you’re here. Don’t worry, it’s first thing I searched after finding the theme.
    (Brackeys Game Jam 2020.2 for those who are a little slow)

  • @andrewkerr9438
    @andrewkerr9438 7 років тому

    So that show to rewind time, THAT'S SO COOL

  • @webosm6494
    @webosm6494 4 роки тому

    A circular buffer is a lot faster and as you setup a maximum amount of time that can be recorded anyway you can initialize a circular buffer right at the start. From that moment you just overwrite values in this buffer. You need two indexes to know at which location in the buffer you are. Often called 'head' and 'tail'. In this particular case you can use only a 'tail' which points to the last index in the buffer that you wrote a value to. Next index is just increasing 'tail' and MOD it with the length of the buffer. This will make it wrap around. For playback you save the value of the 'tail' and decrease the 'tail' and wrap around to the end when 0 is reached and stop when the saved value is equal to the tail. This has only the overhead of a 'tail' index. Also there is no memory management needed as the circular buffer will be allocated only one time and is not changing in size. Fastest way to do it.

  • @jummagamedeveloperbeginner6509
    @jummagamedeveloperbeginner6509 4 роки тому

    I didn't understood the full code, but I saw it worked!

  • @ekimyukselbaba8847
    @ekimyukselbaba8847 4 роки тому +1

    This is killer queen's third ability: bites the dust!!!!

  • @-therebirth7757
    @-therebirth7757 7 років тому

    Finally the actual tutorial about making a replay system.

  • @charbelsarkis3567
    @charbelsarkis3567 6 років тому

    Yòu mentioned you want to put the last location of the object at the beginning because it's a stack. In computer science the stack data structure works by adding to the end of the list and removing the last element instead of the first

  • @atlasentinel
    @atlasentinel 7 років тому +1

    Thanks for your tutorial because since 2 years , I search a video of this type. And You should make a series of tutorial about controll time , like a " bubble of time where there are another timeline in the area

  • @AlexVoxel
    @AlexVoxel 7 років тому +1

    I was wondering how to do this, thank you very much!

  • @Wardy125
    @Wardy125 6 років тому

    You are the best person on the internet.

  • @joshuazollner2995
    @joshuazollner2995 4 роки тому

    I'd recommend using rb.position if we alredy have a Rigidbody Component attached to the object the rewind script is attached to, as this will smooth out the movement even more, especially if the player himself is rewinding. It can cause some shaking back and forth with the camera following the player if Transform.position is used.
    I hope this will help some of you as this was a problem that took me some time to fix

    • @PDCMYTC
      @PDCMYTC 4 роки тому

      Were you able to rewind the player itself too? All of my other objects are able to rewind, except the player, please help me ..

    • @joshuazollner2995
      @joshuazollner2995 4 роки тому

      @@PDCMYTC yes, I was able to get that to work. However, you may need to block the Input made by the player because it can override the position, better said the velocity of your character. If that happens, the player starts behaving very weirdly. You could post a part of your script in here if that doesn't help

  • @stormblessed30
    @stormblessed30 6 років тому +5

    Yaaaaa it’s rewind time!

    • @pathoftraffic
      @pathoftraffic 5 років тому +2

      Umair Khalid that’s hot, that’s hot.

    • @swiwiws125
      @swiwiws125 5 років тому

      Y'know, if I could control Rewind, I would want: Fortnite and *_MARK ASS BROWNIE._*

    • @lhorbrum1818
      @lhorbrum1818 5 років тому

      @@swiwiws125 !emit dniwer s'ti aaaaaY

  • @awesomegamedev
    @awesomegamedev 4 роки тому +2

    To all the jammers coming here for the Brackeys jam:
    4:41 - Please don't do it like Brackeys!
    Inserting/Removing to/from index 0 forces forces all other items in the list to be relocated Every Single Time!
    Better insert/remove to/from the end, although it will also cause occasional relocations (but much rarer).
    Even better to create an array of fixed size and two integers to keep track of the stack begin and end (no relocations ever).
    Between,
    My team is doing a 3D RPG game and we are still looking for extra:
    - Unity dev
    - 2D artist
    PM me in Discord (@Igor Konyakhin)

  • @babywithatank9565
    @babywithatank9565 4 роки тому

    i rewrote this into king crimsons ability. i made it so it removes the players colliders and makes all enemies go and attack your last positions when activated. it then records all of their movements and attacks, after that it resets them back to the position they were at when the recording started and plays all of their movements. i also rewrote that, and turned into his skip time ability by just removing the record and play functions.

  • @seanloughran6714
    @seanloughran6714 7 років тому

    Another optimization you could do is limit the resolution of the savings. Then as you play back LERP between the positions to get smooth transitions between what essentially becomes keyframes.

  • @NSViewController
    @NSViewController 5 років тому +166

    I have a better method.
    CALL WILL SMITH

  • @Lanvill
    @Lanvill 7 років тому

    Wow, you made that look very easy. Love it.

  • @telemonofficial6924
    @telemonofficial6924 5 років тому +7

    -Sees this tutorial
    -opens Unity
    *IT'S REWIND TIME!*

  • @adamih96
    @adamih96 7 років тому

    the data structure that stores both position and rotation is called a transform. If that doesnt exist in unity, it's at least a good name for the script imo.

  • @CamperGuy
    @CamperGuy 7 років тому

    Already looking forward to add this to my project

  • @themannyzaur
    @themannyzaur 7 років тому

    That intro had me hooked

  • @ResoCoder
    @ResoCoder 7 років тому +1

    Thanks for the tutorial! However, using Insert repeatedly is not very optimal. It has to move all of the elements, so just a simple Add() at the end of the list is the best way to do this.

  • @glassystudio
    @glassystudio 4 роки тому +30

    Whos here for the jam??

  • @whyisthismyname6258
    @whyisthismyname6258 6 років тому

    I love Brackeys' tutorials

  • @mrvirtual3928
    @mrvirtual3928 6 років тому +1

    @Brackeys
    you said a swear 13:47
    haha made my day

  • @siank7322
    @siank7322 7 років тому

    Brackeys...you are the best

  • @XOR-lith
    @XOR-lith 6 років тому

    Can't wait to try it out with the new ECS system.

  • @P4D3LL05
    @P4D3LL05 7 років тому

    Cheers love, the cavalry is here

  • @johngrey5806
    @johngrey5806 7 років тому

    Is it possible to give 2 thumbs up??? One question: in the Update method, we're checking if the Return key is pressed as well as not pressed every frame. Wouldn't it be better only to check if it's not pressed if isRewind is true? Or would it not save any processing?

  • @64revolt
    @64revolt 7 років тому

    Thank you :)
    Saw a long and briefly confusing talk by Jonathan Blow how he did his rewind with Braid and he's doing pretty much the same but collecting less frames and then averaging positions from point A B in order to get a higher rewind time. At the least from what I could gather from that talk. As I said, it was a bit confusing :)

  • @theheroofthevirgins1487
    @theheroofthevirgins1487 4 роки тому

    Almost done with the game for the Game jam rewind 2020 everyone looking at this video for help 👌😂 good choice can't wait to see other Gamer games good luck everyone

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

    A game that tries to push forward and make a rewind of 1minute will be god tier

  • @armo0375
    @armo0375 7 років тому

    This will be so useful in racing games! Thanks for the tutorial man!

  • @technoo4891
    @technoo4891 4 роки тому

    Damn, this is amazing, could convert this to 2D and had some cool results

  • @ozi-g-be
    @ozi-g-be 4 роки тому

    Well this video is about to blow up

  • @cyclicyttrium4318
    @cyclicyttrium4318 7 років тому

    You and your patreons are awsome :)

  • @kuylardev
    @kuylardev 5 років тому +5

    Yaaa
    Its Rewind time

  • @adicsbtw
    @adicsbtw 4 роки тому

    I feel like you should also store the velocity so that when the rewinding ends you can give it the velocity at that point in time.

  • @georgeoutters5657
    @georgeoutters5657 7 років тому

    Brackeys you are such a pro. I love your videos. I'm learning so much!!!!

  • @auron2900
    @auron2900 7 років тому

    +1 for the rename shortcut

  • @Oxmond
    @Oxmond 4 роки тому +1

    Cool stuff! Great Tutorial! ❤️

  • @jjxtra
    @jjxtra 7 років тому

    Inserting at position 0 will cause memory copying every time you insert at position 0. I would suggest simply adding via Add() function and then enumerating in reverse order. PointInTime should be a struct as well for additional performance gains. A LinkedList would be even better as you can remove the head and add to the tail basically for free. Finally, if you did something like storing only the changes in position and add a timestamp, you could rewind but not remove the entry in pointsInTime until you go beyond it's timestamp, similar to delta encoding.

  • @ZarkowsWorld
    @ZarkowsWorld 5 років тому

    6:27 - learn usage of guard-clauses. Check if the amount is zero, then set the status that we are no longer in rewind and return.

  • @costin88boss74
    @costin88boss74 4 роки тому +5

    GAME JAM

  • @MegaRomerox
    @MegaRomerox 4 роки тому

    I would only save data when the object is moving, checking it's velocity, and I would save the instant, so that you only save the moments it's moved, and then I'd jump from instant to instant using coroutines in order to avoid active wait.
    I think Brackeys' implementation needs a los of optimization. It can work as an starting point.

  • @sylvainatoz2045
    @sylvainatoz2045 6 років тому

    Wow! Very well explained. Thanks.

  • @davidreichenbach6679
    @davidreichenbach6679 7 років тому +1

    Really inspiring video. Plenty of stuff to do with this, thanks!