Game Development Community

Advanced Camera on dedicated server

by Russell Snyder · in Torque Game Engine · 01/01/2007 (8:53 am) · 3 replies

I'm using Thomas Lund's Advanced Camera (this is a fantastic camera upgrade) I also setup Philip Engdahl's Camera mode cycle fix, (Thanks Philip) it all works great unless I connect to my dedicated server then the advanced camera won't cycle. I believe the problem has to do with getting the advanced camera object over the dedicated server. Philips code uses a global variable to get the camera object when it is created, but this seems to be empty when in client mode connected to server. What am I overlooking?

#1
01/02/2007 (12:16 pm)
Global variables are not shared between client and server. I havent looked at the mode cycle fix code, but from what you tell it doesnt support a dedicated server setup.

You should do some client commands to the server that then cycles the mode. Plenty of examples around for that (if you dont know how).

The camera stuff works in a dedicated server, so its just the cycling part not doing that :-)

Good luck
#2
01/02/2007 (5:52 pm)
Thomas, thank you for the post. I've been doing a lot of forum frolicking and have not yet found an answer to what I need. I believe I need to obtain the id. I have no idea how to do this from client side of a dedicated server.

ClientGroup.getObject(0).getCameraObject() will get me the ID of the advanced camera object but not while connected to the server.

How do I obtain the camera object or even my own player id from the client side while connected?
#3
01/06/2007 (2:31 am)
Hi Russell

I'm in a xmas mood still, so here you go.

You need to understand 2 things
* how client/server commands works
* how the server saves your player+camera on your client connection

First on client/server commands

Simple example. On the client have something like
commandToServer('setCameraMode',"NoseCam")

On the server this now calls a method

function serverCmdsetCameraMode(%this,%mode)
{
	%this.player.setCameraMode(%mode);	
}

The "%this" is just a name for the client connection that send the message. Its automagically available to you.

Read more about this on TDN or search the forums.

On the issue of how Torque saves your player+camera - its almost answered up there.

But try to look in your server/scripts/game.cs

// Create a new camera object.
	%this.camera = new Camera() {
		dataBlock = Observer;
	};

....

         %this.camera.setTransform(pickObserverPoint(%this));

and

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

So once you have the client connection in your hand (automatically received from your server command methods first parameter), you have access to the .player and .camera or .whatever is stored on it.

Thats basically it!