Game Development Community

Engage 3rd person camera view via script at start

by Ben Mathis · in Torque Game Engine · 06/07/2007 (3:47 pm) · 2 replies

Just as the title says. How do I ensure that the third person camera view is engaged using scripts, as soon as the mission starts?

I tried a search and looked through the code, but have come up blank.

More specifically, what is the script equivalent of pressing "tab" to switch to 3rd person, and then where would the resulting line of code go to make sure it's loaded first thing when any mission starts.

#1
06/07/2007 (4:34 pm)
To start the mission in 3rd person view you need to add a line in script to do this, there are a few places where it's possible and I couldn't tell you which is the best/correct one to use as I'm only just starting in torque but a couple of places would be:

in common/server/clientConnection.cs:
function GameConnection::onConnect( %client, %name )
{
...
   ServerConnection.setFirstPerson(false); // added at the end
}


or in starter.fps/server/scripts/game.cs:
function GameConnection::createPlayer(%this, %spawnPoint)
{
...
   %this.setFirstPerson(false);
}


Both work but perhaps someone more experienced can comment if there is a right place to put it and hopefully an explanation as to why.

As a side note you should make sure a couple of parameters in the data block are set correctly otherwise you won't get into 3rd person view, the correct setting should be:
datablock FlyingVehicleData( myFlyingVehicle ) {
...
firstPersonOnly = false;
observeThroughObject = true;
};


firstPersonOnly - Render shape when in first person (only applies to shapes that
are observed through.

observeThroughObject - If true, camera will use this shape's camera parameters, when
this is the controlled object

If you want to disable 1st person view completely then just remove the actionmap or delete the code from toggleFirstperson function.

Hope that helps.
#2
06/11/2007 (4:14 am)
Ah thanks Andy, that worked perfectly! Just the info we were looking for.