0
Answered

Set different timelines for characters

Michał Zardzewiały 6 months ago updated by Lazlo Bonin (Lead Developer) 2 months ago 4

Hi guys, I followed tutorial to make my own game and I am stuck on whiteboxing test level. My question is:

I want to have an option to use rewind like i.e. Prince of Persia, so I can rewind mistake made by player- that means that whole world would rewind, not just enemies (in my case not enemies, but green jelly-boxes). I can't use global time, because if I copy code from

Clock clock = Timekeeper.instance.Clock("Player");

there's an error saying that I can't use clock twice. Any ideas (I am rather newbie, so some detailed-as-for-moron ideas are really welcome)?

EDIT: I've created Global Clock for Player, so other button rewinds whole time, including main character, but here's different question: is there a way to stop rewinding automatically, let's say, after 5 seconds? Right now I have to use another button to "play" world in normal timeline

Yes, I know about Recording Duration in Timeline, that solves one problem, but it would be awesome to automatically play game after that Duration without need to push another button ;)

Chronos Version:
Unity Version:
+1

Use a timer that receives unscaledDeltaTime, when the timer reaches the value you want (5 seconds), stop rewinding time

check the pseudo code below

float timer = 0;

Update(){

     timer += unscaledDeltaTime

     if(timer > 5){

        stop rewinding

    }

}


+1
Under Review

Question 1: You can use Local Clocks or Global Clocks perfectly fine for this, what exactly is the error you are getting?

Question 2: You can also schedule an occurrence 5 seconds in the past which sets the time scale to zero!

Hi Lazlo, thanks for reply. I already solved first error (just being moron that doesn't red documentation more than once- I used one variable twice with hope it will work :D)

Also, great thanks for Giovanni Sales - great idea, will try it tomorrow morning; if it will work, I can make time rewind like in Prince of Persia, that works only for a bit of time- not "let's run through level once again" ;]

I hope I won't bother you with that kind of stupid questions. Thanks again, I really appreciate your help!