- Home /
How to create a system to go back in time as in Prince of Persia?
Well, I would like to create a system that allows the user to go back in time in the style of Prince of Persia, but I have no idea how to record the movements made, and then pressing a button, load the recording in reverse order .. .
Could you help me with some code or idea?
Thanks in advance...
Answer by GeekURLant · Feb 09, 2011 at 02:39 PM
Hi,
Maybe you should record the types/order of the player's animations and his movements on x seconds (or when the player can reverse time). Whenever the player's animation change, you store the animation ID an array with the player's position in the Update function.
And when the player press the "reverse" button, you read the array.
Dunno if I was clear enough but hope it will help you.
Rather than trying to record all the animations and play them back in reverse order it may be easier to record the transform of the character and the transform of each bone, and then play that back ins$$anonymous$$d.
Answer by pet1100 · Mar 14, 2017 at 11:43 AM
Use linkedlist. When the list is x in size you can remove the first and still add last.
And example: LinkedList reverseTime = new LinkedList();
In every update AddLast Remove first if LinkedList size is to big
Remember to do it on visible enemies.
The movement class should consist of transform (orientation and world position) and or more info depending on gamemechanics.
Please edit your answer and mark your code as code. Also you most likely had used generic arguments which has been stripped since the weren't marked as code so they got interpreted as HT$$anonymous$$L tags and stripped away.
If you don't know how to format your code, see the user guide section "Posting Questions, Answers and Comments"
(i wish Unity would finally add anchors to their html documents. It's a pain to link to a long page without a way to go to a specific section ...)
Answer by AtomicMarine · Feb 09, 2011 at 02:50 PM
Or you could make the timescale negative?
TimeScale = -1.0
or something like that, look up the TimeScale method it is used to slow down time in my game, and should be able to reverse it.
I don't know if unity handle the "recording" part of what we are talking about ... but it would be amazing if it was this simple =D
Nope, sorry. Time is simply stopped at any value less than or equal to 0.
@swordofnoah : Time is not stopped at negative timeScale, deltaTime is negative so movements can be inversed that way but not reversed. Furthermore Physics (FixedUpdate, Collisions, Trigger...) is not considered anymore.
Your answer
Follow this Question
Related Questions
Play the same animation offset in time from another object? 0 Answers
Voice Recording issue ?? 0 Answers
get particles at certain time 0 Answers
360 stereo video double vision 0 Answers
Dynamic recording of objects position seems fine, playback is too fast. 2 Answers