Game Development Community

Using second camera

by CodingChris · in Torque Game Engine · 12/20/2007 (3:31 pm) · 2 replies

Hi,
sorry for the silly question, but how to use a second camera?
What I want to do:
I've got the default camera moving with the player.
During a special event I want another camera just to show a static view.
I can simply create the second camera in the mission editor, but how do I use this camera?

#1
12/21/2007 (6:50 am)
To put it simply you need to set the camera object used by the client connection from the server.

Here is an example that you could use in the console, this assumes your camera is named 'camera1'.
LocalClientConnection.setCameraObject(camera1)

I use an ever slightly more complex method that will work over a real network connection.
// This must be accessible to the client scripts
function setCam(%camera)
{
   commandToServer('setCamera', %camera);
}

// This must be placed in the server scripts
function serverCmdSetCamera(%client, %camera)
{
   %client.setCameraObject(%camera);
}

These methods are only needed if you want the client to be able to trigger the camera change (excellent for debugging purposes). If you are triggering the camera change from a trigger callback your should just set the new camera object on the client directly cutting out the server command call.

Be careful as changing viewpoints may cause strange things to happen if your not prepared for them . Ask questions when needed.
#2
12/22/2007 (9:13 am)
Thanks, that helps me a lot.