Game Development Community

Stopping all movement while a timer counts down

by Neil Marshall · in Torque Game Engine · 08/21/2002 (5:17 pm) · 9 replies

I'm trying to display a count down from 10 and when it hits 0 I want the player to be able to move. Does anyone have any suggestions on how I would go about stopping the selected clients from moving? (I don't want all the clients to stop moving. Spectators should still be able to move)

#1
08/28/2002 (2:42 am)
%player.setMoveState(true|false);

I think this is it. The function is a part of T2, however Im not sure if Torque kept it.
#2
08/28/2002 (7:26 am)
I can't seem to find a function like that but it appears that there is a function

%player.getState() which seems to alternate between "Move" and "Dead".
#3
08/28/2002 (7:39 am)
You could push the players to a camera view, then when the counter reaches 0 give them control of thier player.
#4
08/28/2002 (7:53 am)
Or, what I did - pop the moveMap for that period like that:
I got a function in client/scripts/client.cs:
function clientCmdToggleMoveMap(%val)
{
	if(%val)
		moveMap.push();
	else
		moveMap.pop();
}

which I call from server/scripts/player.cs for example:
commandToClient(%this.getControllingClient(), 'toggleMoveMap',0);
#5
08/28/2002 (8:42 am)
Another option is to spawn the players, attach the client to the player, but don't give them control until the timer runs down.

In game.cs you'll find this function:

function GameConnection::createPlayer(%this, %spawnPoint)

At the end of the function is the following code.

// Update the camera to start with the player
   %this.camera.setTransform(%player.getEyeTransform());

   // Give the client control of the player
   %this.player = %player;
   %this.setControlObject(%player);

What you will need to do is add a condition around the setControlObject call so it isn't called while the countdown timer is active. Then when the timer runs out you will need to run through the Client pool, see if they have a Player Object and call setControlObject for each of them.
#6
08/29/2002 (10:39 am)
To get to the starting grid, I'm just changing the players transform, I'm not actually spawning the character. Are there benefits to spawning the character?

I wish I knew the relationship between the player and the client better.
#7
08/29/2002 (12:04 pm)
%client is the connection to the game server, ie the network connection.

%player is the model that the client controls within the game.



During gameplay each %client will always have the same ID number, but during that time they can control many different %player objects.
#8
08/29/2002 (12:06 pm)
Okay, then I guess I was right about that...
But if I spawn the player at another point on the map, will the skin/model be the same? I'm thinking it won't as that's probably stored in the %player.
#9
09/02/2002 (12:34 pm)
I tried the moveMap method and, while it worked, it locked up the camera a little more than I was expecting. I couldn't do any keyboard commands at all.

So I tried the .setControlObject method.

I'm setting the control object to the camera, then put the camera into an orbit mode. Then when the race starts, I set it back to the player and everything works fine.

Here is how I did it for anyone who may be interested:

//Lock the player
%client.camera.setMode("Locked", %client.player);
%client.setControlObject(%client.camera);

// Give control back to the player
%client.setControlObject(%client.player);

Then in Camera.cs, I copied the "Dead" code and named it "Locked", at the same time I removed the spawn code.