Game Development Community

Advancing the simulation by a fixed amount

by Timlon · in Torque Game Engine · 10/02/2005 (7:12 pm) · 20 replies

Hi,

Is it possible to advance the engine based on an amount of time I specify rather than the real amount of time that has gone by. Examples of use would be to pause the game in the state it is, save a screenshot to disk without the game lurching forward due to the lag..etc.

So basically I want to say "only 10ms have passed" or similar and the game update accordingly.

Any help much appreciated.

#1
10/02/2005 (9:09 pm)
You could play with $timeScale a bit for similar results.
#2
10/03/2005 (6:48 am)
Thanks Matt I will have a play :)
#3
10/06/2005 (7:10 am)
$timescale = 0 is a nice way to pause the game. It will pause anything that updates based on the sim time.
#4
10/06/2005 (7:34 am)
That's bang on what I was after :) Thank you very much :)
#5
10/06/2005 (12:48 pm)
OK, need some more help if that's possible (please) :)

$timescale = 0; works fine in the console, however where I am using it, it seems to have no effect:

function movieGrabScreen(%movieName, %frameNumber)
{
$timescale = 0;
screenshot(%movieName @ formatImageNumber(%frameNumber) @ ".png" , "PNG" );
$timescale = 1;
$screenGrabThread = schedule($timeAdvance, 0, movieGrabScreen, %movieName, %frameNumber + 1);
}

Basically the idea is that everything waits while the screenshot is being saved so the screenshots can later be turned into a movie after being batched through photoshop and some other things.

The other problem I have found with $timescale is that it doesnt affect the sun or water - they keep going on regardless (i suspect the clouds do also).

Any solution where I can freeze the whole game dead, save my screenshot, and then carry on like no time has passed whatsoever?

Thanks in advance :)
#6
10/06/2005 (8:53 pm)
Is it a typo in copying the code that you forgot a $ in front of the word timescale in the first line of your function?
#7
10/07/2005 (2:03 am)
Yes that's a typo - the actual code has the $ (have edited on here now).

Strangely, if I comment out the screenshot the whole thing runs at lightning speed rather than freezes.
#8
10/07/2005 (2:41 pm)
Update: Saved out a played back demo as frames, built into an avi - the players and i *think* the particles are ok - however the water and sky look really weird as they never pause with $timescale = 0;

I guess my question is - how do i freeze everything including the water etc so I can take a screenshot an then unpause without the engine thinking any time has passed (a $timescale = 0 type solution that effects everything).

Heres hoping for a response :)
#9
10/08/2005 (12:31 am)
Didn't try this myself, but I think you should use a different approach, basically because you can't play the game anymore with all the starting and stopping and the movie would look very strange (I think).

So I would look for a piece of code to limit the frame rate to, say, 20 fps, and then try the brute force approach (my favourite :-): fire a screenshot every screen update.
#10
10/08/2005 (12:51 am)
I believe you will have to set $timescale = 0 on the server. If you are doing it during a screenshot you are most likely doing it on the client side.
#11
10/08/2005 (3:37 pm)
Thanks for the replies guys.

My last post wasnt well explained. $timescale = 0 *is* working fine, it pauses now to save a screenshots, then unpauses after. The problem is that not everything is affected by $timescale.

The problem I have is that using $timescale = 0 does not stop water, sky or the sun - they are completely unaffected (everything freezes in mid air while the water for example moves unaffected).

I guess these parts of the engine are seperate to the rest - any ideas how I can freeze those?


BTW - @Dirk - I'm not playing when i'm taking the screenshots, just playing back a demo of a previous game.
#12
10/09/2005 (12:00 am)
@Timlon: I see.

I still would it do 'my' way. It's obvious that some of the effects are not influenced by the timescale (I guess because someone felt that these are not gameplay intrinsic) so my guess would be that there are many more pieces of the engine to be changed than just the two I mentioned.

Plus this would give a nice create-a-movie extension for the ressources.
#13
10/10/2005 (6:01 am)
I see your point Dirk but I don't want to risk a jump in the action - I could just use fraps but it can jump on occasion due to resources available, calling a screenshot every so often would leave itself open to the same problem. The only way to be sure of a glitch free end result is to be able to halt everything, take the screenshot and then resume with the engine thinking no time has passed.
#14
10/26/2005 (8:00 am)
Maybe someone with knowledge of the engine itself could advise me here?
#15
12/05/2005 (3:02 am)
Anyone?
#16
12/05/2005 (3:44 am)
Can I ask why you want to do this? Why not just use Fraps then? Do you really need it to be "glitch free"? You'll hardly notice it.
#17
12/05/2005 (5:02 am)
The best way tor ecord a movie, IMO, is play the game with -jSave to record a journal, then playback the journal and use Fraps to record.

When you use -jPlay, the game will run at a fixed frame-rate. For maximum effect, do the recording with all details settings at the lowest level, and then change the prefs file to maximum quality before playing back the journal. Just make sure you don't change the resolution, because that'll make the mouse input data in the playback be slightly different, and you'll see errors, like characters running into walls.
#18
12/05/2005 (9:47 am)
Excellent - thank you Manoel :)
#19
12/05/2005 (11:20 am)
@Burning - It is for a DVD Video, hence why it needs to be 100% right, "hardly notice it" won't cut it unfortunately.
#20
12/05/2005 (11:23 am)
Manoel's idea is a good one, but I can see instances where I will need to change resolution, so I need to record demo's rather than journels I guess which still leaves me the problem of pausing everything.