Game Development Community

Pause Game / Schedule() Help PLZ

by Travis Hoffstetter · in Artist Corner · 08/30/2006 (1:35 pm) · 7 replies

In game, when the player hits a certain trigger, a small window gui pops up on a screen with a message. My problem is that while the gui is up, the player can still walk around. Does anyone one know a way to pause the game or a work around?

I tried to use the schedule() command to pause the game, like mentioned in previous forums. First i tried: schedule(100000,0,0); this didn't pause the game. Then i tried schedule(100000,0,Canvas,setContent(P1)); and this popped up my gui named P1, but it never paused the game. A point in the right direction would be greatly appreciated.

#1
08/30/2006 (1:38 pm)
$timescale = 0

a friend showed me this neat trick. =) note that you can also set it to values between 1 and 0 for slow-mo type stuff.
#2
08/30/2006 (1:59 pm)
Can you elaborate on how to use that a little more please Sean?

In my trigger script, in the onEnterTrigger function for my trigger, i am adding my code. In the that function I typed,

$timescale = 0;

and this stopped my level from loading at all. Then I tried

schedule(100000,0,$timescale = 0);

and this also prevented me from loading my game.

I guess I just don't understand how to use it correctly. If you could give me an exmaple call, that would be great. Thanks
#3
08/30/2006 (2:45 pm)
Oh ok so you're loading a level when the player enters a trigger? well i guess you can't use $timescale since that stops all the engine processing. if you just want to prevent the player from moving while the gui is on the screen, just disable the movement functions. or you could temporarily disable the directInput.
#4
08/30/2006 (3:02 pm)
I use a custom timescale variable that is implemented on a per-object basis. This is because some objects I want to continue to animate (such as animated gui elements, the camera and such). It helps to understand the nature of processTick and advanceTime. processTick happens at a regular interval, so that the game simulation runs the same no matter what the render framerate is. advanceTime happends once per frame. Calculations that are essential to gameplay (such as positioning of characters and physics) should happen in processTick, while aesthetic things should happen in advanceTime.

OK, this is a little off topic from your question, but I think this is a subject that is not very well understood by many Torque users.
#5
08/31/2006 (7:02 am)
My trigger isnt loading a level.

when i put:

$timescale = 0;

as line in my trigger on enter function, my level containing the trigger wouldn't load from my main menu gui. When I took that line out, my level would load again. Do you know whet script file handles movement functions, or the lines of code to disable and reable the functions?
#6
08/31/2006 (8:24 am)
Travis do you start the level inside the trigger? If not, I dont see why putting that line in the onEnterTrigger would cause the level to not load at all since it should only be called when you enter the trigger.

theres a function called disableinput() or something like that. do a little research. that function should do the trick. or you could activate a package in the on enter function which overrides the functions for capturing keyboard input. i believe these functions are located in default.bind.cs or config.cs. I'm not sure about the 1.4 scriptbase though.

you should be able to figure this out.
#7
08/31/2006 (12:25 pm)
Okay, so I've been giving this all a lot of thought and looking at the files and what not. I couldn't find the disableinput() function but then I thought, why dont i just unbind the keys a,s,w,d when the player hits the trigger and then rebind them when the player clicks on the return to game button. So I added the unbind commands to my onEnter function.

//Initialize Trigger
datablock TriggerData(OpOrder)
{
tickPeriodMS = 100;
};

function OpOrder::onEnterTrigger(%this,%trigger,%obj)
{
//display my small window gui to the screen
Canvas.pushDialog(Drive);

//unbind the movement keys so the player cannot move around while the window gui is on screen
moveMap.unbind(keyboard,a);
moveMap.unbind(keyboard,d);
moveMap.unbind(keyboard,s);
moveMap.unbind(keyboard,w);
}

the problem is that that my movement keys are unbound when the level starts, but my gui window doesn't pop up until I enter the trigger. The player doesn't start in the trigger, but well away from it. This is so weird and is probably why i had problems putting in the $timescale = 0; line.

I tried putting the unbind commmands in their own function and calling that function from within the trigger on Enter and I had the same problem. However, if I didn't call that function from onEnter, but left it in the code, my movement keys did not get unbound.

I don't mean to sound like too much of a noob here, it just doesn't make sense that some commands aren't called till I enter the trigger but others seem to just start on their own, even though they're all not supposed to be intialized until the player enters the trigger. Should I try using a different type of trigger?