Mini-tutorial: Enter Torque as an observer
by Mike Stoddart · in Torque Game Engine · 01/09/2004 (5:49 pm) · 5 replies
I thought I would just post this little snippet for those new to Torque.
Currently, Torque spawns new players into the game. This little script snippet (hopefully!) changes that so you spawn as an observer instead.
in ~/starter.fps/server/scripts/game.cs in the function:
comment out:
And add the following:
I've only tested this on my local modified copy of Torque, so hopefully it works for other people.
Currently, Torque spawns new players into the game. This little script snippet (hopefully!) changes that so you spawn as an observer instead.
in ~/starter.fps/server/scripts/game.cs in the function:
function GameConnection::onClientEnterGame(%this)
comment out:
//%this.spawnPlayer();
And add the following:
%spawnPoint = pickSpawnPoint(); %this.setControlObject(%this.camera); %this.camera.setTransform(%spawnPoint);
I've only tested this on my local modified copy of Torque, so hopefully it works for other people.
#2
In common/server/missionDownload.cs of the Torque Demo, we have the function GameConnection::loadMission(%this).
In it, is
How do I enable the AIControlled() to make the observer mode works for me?
Regards,
James Yong
01/10/2004 (8:01 pm)
Hi,In common/server/missionDownload.cs of the Torque Demo, we have the function GameConnection::loadMission(%this).
In it, is
Quote:
if (%this.isAIControlled())
{
// Cut to the chase...
%this.onClientEnterGame();
}
else .....
How do I enable the AIControlled() to make the observer mode works for me?
Regards,
James Yong
#3
I think what your asking is, "How do I get my client's camera to chase an AIPlayer?"
Here is how I did that:
in ~/client/scripts/default.bind.cs I added:
To force the new key binding to take affect, you will need to delete ~/client/config.cs and ~/client/config.cs.dso
Then I added this to ~/server/scripts/aiPlayer.cs
In the above code $testplayer points to an AIPlayer. You may want to change this to something fitting your code context.
To use this new feature, press alt c in the game. Then press c. pressing c again reverts the camera back to fly mode. pressing alt c again reverts the camera back to the client player.
03/08/2004 (7:39 pm)
@ YongI think what your asking is, "How do I get my client's camera to chase an AIPlayer?"
Here is how I did that:
in ~/client/scripts/default.bind.cs I added:
function cameraChaseBot(%val)
{
if(!%val)
return;
// ~/server/scripts/aiPlayer.cs has serverCmdtoggleCameraChaseBot()
commandToServer('toggleCameraChaseBot');
}
moveMap.bind( keyboard, c, cameraChaseBot);To force the new key binding to take affect, you will need to delete ~/client/config.cs and ~/client/config.cs.dso
Then I added this to ~/server/scripts/aiPlayer.cs
$cameraIsChasing = false;
function serverCmdtoggleCameraChaseBot(%client)
{
if($cameraIsChasing)
{
%client.camera.setFlyMode();
$cameraIsChasing = false;
}
else
{
%client.camera.setOrbitMode($testplayer, "0 0 0 0 0 0", 6, 9, 8, false);
$cameraIsChasing = true;
}
}In the above code $testplayer points to an AIPlayer. You may want to change this to something fitting your code context.
To use this new feature, press alt c in the game. Then press c. pressing c again reverts the camera back to fly mode. pressing alt c again reverts the camera back to the client player.
#5
03/09/2004 (9:12 am)
Useful, thanx.
Associate Kyle Carter