Time Scale Question

0 favourites
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • I'm trying to implement slow-mo into my replay mode, the replay logic I took from the legend R0J0hound's logic which he posted 8 years ago (Which is so relevant and useful even today).

    My question is If I put a time scale of 0.5 everything becomes slower except the sprite which the replay mode logic is integrated. How do I make it slow-mo?

    Tagged:

  • your game is still running at 60 frames a second, but with a time scale of 0.5 it just updates things less often (things that are aware of the time scale) even though each tick happens at the normal speed.

    the playback from ROJOhound's file updates the sprite position every tick, so it is still moving at the normal speed. You would have to "play back" every entry in the array twice to make the sprite move at half the speed.

    if your game doesn't maintain 60 frames a second, then you may need to save dt as part of each entry in the array and then calculate exactly when each play back frame needs to be displayed.

  • Thanks, AllanR, for your response. Could you be more specific or can you provide an example or something? I'm not quite familiar with those dt and stuff.

  • here is a sample of ROJOhounds file that plays back at half the speed (although the new player sprite continues to record at the normal rate.

    if you change the slowfactor variable to 3, it would play back at 1/3 the normal rate. This doesn't use dt so it assumes game plays at a steady 60 frames a second...

    https://www.rieperts.com/games/forum/slowmo.c3p

  • here is a sample of ROJOhounds file that plays back at half the speed (although the new player sprite continues to record at the normal rate.

    if you change the slowfactor variable to 3, it would play back at 1/3 the normal rate. This doesn't use dt so it assumes game plays at a steady 60 frames a second...

    https://www.rieperts.com/games/forum/slowmo.c3p

    Thanks, AllanR, that was neat, Working exactly how I wanted.

    One problem with my setup, I need your suggestion.

    On my setup, I created a layer called "ReplayLayer" and invisible it on the start of the layout. when the player completed his task, I turned the "ReplayLayer" to visible and wait for 6 sec and then make it invisible (so the user will view the reply automatically) Why 6Sec? Because this much time it required the Replay to finish. That is how I throw the reply to the user, the 6 sec time bracket was perfect for that setup. But now with the slow-mo setup, the 6-sec bracket become 20+ secs, this is where I need your help? How to record only last 1 or 2 sec so that slow-mo will only last 8 to 10 sec. Or do you have any suggestions to improve my setup?

    Thank you, I'm looking forward to your responce.

  • to record only the last seconds you just have to start deleting elements from the array once it has reached the desired playback length.

    every new frame is added to the back of the array, so you need to pop the first element in the array to remove that.

    this will help prevent the array from getting massive if game play goes on for a long time.

    if the player manages to die in under 2 seconds, you can calculate how long to show the replay layer by taking the width of the array, divide by 60, and multiply by 2 (since you are playing back at half speed).

    if you want more than just the last 2 seconds, you can set a variable to how long the array should be, and then use the method above to calculate exactly how long the replay will take to play back. In my example I record the last 3 seconds...

    https://www.rieperts.com/games/forum/slowmo2.c3p

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, AllanR,

    I still struggling to make it work in my setup, Initially, it works but after some time the reply sprite completely vanished. If I make it 1000 (The RecordLength) it stays more time before it has gone. and out of sudden, the SLOMO completely stoped working. lol. I must be doing something wrong. Still trying to fig out. Will come back and share my exp.

    Good Night (Day).

  • once you get to the end of the array there wont be any data to position the replay sprite with. so it will be setting its animation, frame and position to nothing. you want to stop playing the replay when it gets to the last entry in the array. (which will be array.width -1)

  • Hi, AllanR.

    If it only records what we put on "RecordLength" here in this case 180 (For 3 sec) once 3 sec passed it will not record. In my setup when the user completes his task, I want to show the recoding automatically before the GAME COMPLETE popup. At the start of the layout, I started the recording to ON, and it automatically finished recording after 3 sec (as per the "redcordLenght Logic"). So the problem is when the user completes the task maybe after 20 sec, there would be no recording to show to the user once I unhide the REPLAY layer.

    It is more confusing than it seems I would say, maybe I not understand it fully yet.

  • the example I posted saves the last 3 seconds, not the first 3 seconds.

    it takes 3 seconds for the array to fill up, but after that it starts deleting from the start of the array, and adds the latest player data to the end of the array. (so you always have the last 3 seconds of data)

    you could easily record the entire run, and only replay the last few seconds, or let the player decide how much to replay... you could also make a system to save the recording so that they can show other people, etc.

  • Hi, AllanR, One question regarding the recordings, I have integrated the recording logic to an enemy, and it works perfectly (not slow-mo), but when I have multiple instances of the same enemy the reply shows only for one instance of the enemy, Can it possible to track the movements of all instances of the same object using the same logic (maybe using "each" loop or something) or it is not possible we must need a separate array for each object or separate row/column for each instance?

  • The example I made was obviously based on the file made by ROJOhound. He made the player a container and put the array in that. If you set up enemies the same way then each instance would have their own array. You would need a For Each Enemy loop to play back the recordings.

    the potential problem is if you kill an enemy, then the array will get destroyed with the enemy - making it impossible to play back. If enemies spawn and get killed regularly you will need a playback array that works differently than the player's array.

    if all the enemies exist at the start of the layout, and they don't die, then their recordings would line up with the player and play back correctly. If enemies spawn after the start, then they would have to use the frame counter from the player so that their recording will match up with the player.

  • Thanks, AllanR, for the response. Now I got it. :)

  • you could easily record the entire run, and only replay the last few seconds, or let the player decide how much to replay... you could also make a system to save the recording so that they can show other people, etc.

    Saving the recording sounds damn interesting, I will try to implement it for sure, Just wondering what would be the best way to do this, do we need to Record everything to a different ARRAY simultaneously?

  • As usual, there are probably lots of ways to do it. It depends on how your game works, how long a typical run takes, how many enemies there are, do they exist for the whole run, do they spawn at the same point or do they randomly spawn, do they shoot at you, do you shoot at them, etc.

    ROJOhound's method records the Player's X, Y, Animation, Frame, and width every tick. If there isn't randomness to the game you could instead save the player's input and then have everything respond to the input in the same way to recreate what happened. There is also the Game Recorder object that can record a video of the canvas. I think that was meant to allow you to download the video, but it might be a way to play back exactly what happened without having to save all the things that move separately.

    The more that happens in your game, the more you have to save - and the more memory required to do that.

    One of my favorite games is Jetpack Joyride. At the end of a run they show you a snapshot from the run. Showing an instant replay is a lot trickier...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)