0

What does the -1 in "clock.localTimeScale = -1; // Rewind" represent?

Rich C 11 months ago updated 11 months ago 2

I'm considering buying Chronos, and not just because of the amazing trailer. My game involves a player which moves 1 unit at a time. Imagine a chessboard type setup.

When the W key is press, the player moves forward 1 unit. Now, due to some processes, I want to be able to reverse the players moves to a certain point. For example, W was pressed 3 times, two times too many. I want to be able to "reset" the players position.

Now, I have read https://support.ludiq.io/knowledge-bases/2/articles/3-can-i-replay-scrub-import-or-export-the-rewind-data. I understand that "scrubbing" is not possible. However, when I look at the tutorial, I see:

        // Change its time scale on key press
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
                 clock.localTimeScale = -1; // Rewind
        }

This brings up the question: What does -1 represent? Is it 1 unit (world unit space) backwards? Is it 1 second in time backwards? Is it 1 frame backwards?

Chronos Version:
NA
Unity Version:
Unity 5, 2018.2.13

I'm a user, not a Chronos developer or Community manager.

TL;DR: -1 means playback speed by normal speed

As my understanding, it works like Unity's Time.timeScale.

In each frame, Unity's Time.deltaTime return the time difference from the last frame. Meanwhile Time.timeScale is the scale at which the time is passing. Time.timeScale works like the multiplier to Time.deltaTime.

It's maybe something just like this in somewhere of the Unity Code.

Time.deltaTime = Time.timeScale * (Time.time - previousTime);

The default Time.timeScale value is 1.
If Time.timeScale > 1: The game speed 2xtime faster.
If Time.timeScale > 0 but < 1: The game speed will look like the slow motion.
If Time.timeScale = 0: The game will pause.

(More info here: Unity Time Scale)

Chronos' timeScale works the same way as Unity's timeScale.

But Unity's Time.timeScale can't be lower than 0, the Chronos' timeScale can.

When the timeScale is below 0, Chronos will switch mode to play record instead of playing update. If timeScale = -1 game will play record backward in normal speed.

timeScale can be found in the 'Timeline'. This is the value you can 'get'. To check which state of time flow of the current object use this.

localTimeScale can be found in the 'Clock'. This is the value you can 'set'. If you want to change the state of time flow use this.

Get back to your game, I don't have enough information about your game to describe much. But if you only want to reset, you can simply save position, rotation at 'Start' and set it back when reset.

But if you want is to rewind with a cool looking presentation. Chronos is your way.

Hope this can help.

Thank you very much for your time, I really appreciate it.

I think what you say makes sense. It looks like I'll have to just implement my own system - it shouldn't be too difficult.

Thanks again ;)