Game Development Community

Load looking through static camera

by To-mos · in Torque Game Engine · 12/02/2010 (4:10 pm) · 4 replies

Hello, I'm working on a FPS game with the starter kit and have a menu that loads a mission in the background so it's a live background. What's happening is the player spawns and its looking through the first person camera. SO what I have is placed a camera and used LocalClientConnection.setCameraObject(menu_camera) under the loadMainMenu function in init.cs under client. The problem is when the main menu loads its still looking through the player although i can hit alt+c and look through the menu camera. What I'm looking for is to load and look through the map placed camera instead of the player. I'm very new to torque so if I'm completely going the wrong direction with this some help would be nice. I used the resource about loading a mission as a menu.

#1
12/04/2010 (1:23 pm)
You need to set the control object as the camera.
LocalClientConnection.setControlObject(menu_camera);
Make sure you call them in the right order though, since not having a control object when the TSCtrl awakens will crash the client.
You may also need to disable any action maps if you haven't already.
#2
12/04/2010 (3:58 pm)
I've tried that before but maybe I did it in the wrong order? It seemed like it just spawn the player and ignored the camera. Also, would I have to return control to the orbital camera when starting a game or does the engine do that already? I have no idea what the name of the observer camera is so I wouldn't know how to return the controls.
#3
12/05/2010 (12:41 pm)
You might be trying to set the camera and control object before the player has been created. You might want to create a new gametype specifically for the mainmenu so it does not spawn the player.
Also, the local connection (or client) holds the info for the player and camera assigned to the client. LocalClientConnection.player will return the player and LocalClientConnection.camera will return the camera.
Without looking at the scripting you are using, I cannot tell where the fault lies.
#4
12/05/2010 (3:33 pm)
I used this resource http://www.torquepowered.com/community/resources/view/4171 called mission in main menu GUI and modified the function loadMainMenu() to this

$mainMenu = false;
function loadMainMenu()
{
// Startup the client with the Main menu...
$mainMenu = true;
createServer("SinglePlayer", expandFileName("~/data/missions/mainmenu.mis"));
%conn = new GameConnection(ServerConnection);
%RootGroup.add(ServerConnection);
%conn.setConnectArgs($pref::Player::Name);
%conn.setJoinPassword($Client::Password);
%conn.connectLocal();
LocalClientConnection.setControlObject(menu_camera);
LocalClientConnection.setCameraObject(menu_camera);
Canvas.setContent( MainMenuGui );
Canvas.setCursor("DefaultCursor");

// Attempt to load a set of datablocks for use in a player picker
if (isFunction("loadPlayerPickerData"))
loadPlayerPickerData();
}

I notice when I delete the player spawn point from the mission, it starts the main menu looking through the camera and the lighting hasn't kicked in it's just fully lit terrain. Then the terrain darkens to what I have the light set to and then the player spawns in the air and the camera changes to the player. If I keep the spawn point in it just spawns the player looking through its camera but the terrain is already lit correctly. It's very confusing for me I hope this helps.