REWIND TIME in Unity
Video Statistics and Information
Channel: Brackeys
Views: 288,134
Rating: undefined out of 5
Keywords: brackeys, unity, unity3d, asset, assets, model, models, beginner, easy, how, to, howto, learn, course, series, tutorial, tutorials, fix, tip, game, development, develop, games, programming, coding, basic, basics, C#, reverse, rewind, winding, back, time, reversing, rewinding, control, manager, manage
Id: eqlHpPzS22U
Channel Id: undefined
Length: 14min 15sec (855 seconds)
Published: Wed Jun 21 2017
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
If you're using a List<T> to store your time points you should add to the back of the list and then remove them from the end.
The way you're doing it every time you insert into the array (at position 0) requires shifting all other elements in the array up one index (requires traversing over the entire array and performing a per-item copy for each other item) and every time you remove from the array you pay the same performance penalty but in reverse (shifting down instead of up). Adding to and removing from the back of the list is a single operation.
But really you should look into using a deque data structure or anything else that supports efficient addition/removal from both ends of the list (to support both appending time points and discarding time points outside your recording window).
Just wanted to say that I thought this video was extremely well done. I had a project where I had to create this same system, and yours was definitely implemented much cleaner and easier to understand, which helped me think about my own! Really well explained and demonstrated, and it was succinct on top of that.
Very nice work! Hoping to see more of your stuff!
Cool tutorial for newbies, really clear and concise.
System.Collections.Generic has a class called Stack which is much more appropriate here.
You also might wanna consider using a struct instead of a class.
For more time control stuff, Chronos is a pretty decent asset store package.
I actually came up with a similar system some time ago when I was trying to visualize a concept that came to my mind after reading Steins;Gate. And then, as always, I gave up and never came back to this project.
Still, time manipulation is just a different level of amazing :D:D
Edit: Thanks for tuning in at Brackeys!
Nice simple explanation. Great job and thanks!👍
Recommend Chronos for anyone who actually wants to use this in a game
The real concern would be dealing with animations. I'm sure there's tutorials for a sports-like replay system.
With things like this is it more intensive on the game to record and store values each time step or instead store them at longer intervals and interpolate between the values when rewinding time?
Both of those operations are pretty quick on their own but I figure that constantly messing with a data structure is going to be slower than doing the interpolation math during a rewind only.
Is this assumption correct?
Was happy with myself, I had my first instance of thinking "wouldn't it be a good idea to make those pointsInTime variables a struct? I'm learning!
But I always think these sorts of tutorials should be taken as jumping off points. Things won't always be done efficiently or in the "best practices" way, but the point is more to get us noobies understanding the process and piecing together the tools available to get a result we can build off of.
The discussion about the lists has probably led me to learn more about the available options than if he simply used a Stack in the first place.