Game Development Community

questions about setting camera

by Sen · in Torque Game Engine · 03/27/2010 (6:48 am) · 1 replies

Hi, guys

I have an aiPlayer in the scene(a submarine), and some buttons on the screen to control its movements. When the game starts, control object is set to be the avatar(a warrior).

Here is what i want to do:

1.where can i get a handle of GameConnection object, so i can switch control object or spawn a new camera.
I searched in all scripts there are six places which have statement as "%conn = new GameConnection(ServerConnection)" from which should i get the handle?

2.How can i create a third person chasing view cam and link it on the aiPlayer model by the handle i get above?

3.I'm also confusing about the arguments from a few functions because there's no way to check how many parameters one function is supposed to receive, for example:

fucntion GameConnnection::spawnPlayer(%this, %spawnPoint, %noControl),
it gets 3 parameters and first one points to itself. however, in another function

function GameConnection:: onConnect(%client, %name) , there 's not a "%this".
I didn't see their original forms in source code, just wondering is this because in their original forms the arguments are set fixed and we have to follow the way when we override in script.

Thanks in advance for helping me out.

About the author

Recent Threads


#1
03/29/2010 (5:24 am)
GameConnnection::spawnPlayer(%this, %spawnPoint, %noControl);
this is a method of GameConnection i.e. it will spawn a player at the given spawn point (not sure what the %noControl param is for)
GameConnection:: onConnect(%client, %name);
this is an callback. it is executed when the GameConnection...connects. The %client param is the id of the connection and the %name param is probably the name of the connection like ServerConnection, ClientConn, etc.

It is probably easiest to place the GameConnection id (%this) in the player object:
//in GameConnection::spawnPlayer
%player = new Player()
{
   datablock = playerDataBlock;
   client = %this;
}
%this.player = %player;
//not sure if this is safe for an online game though. might provide a hole for a hack snake to slither thru.
that way you can access the GameConnection thru the player:
%gameConn = playerName.client;
to switch control objects use setControlObject()
%gameConn.setControlObject(newControlObj);
not sure what you're trying to do with the aiPlayer and chase cam thing.