Game Development Community

dev|Pro Game Development Curriculum

Removing First Person Camera

by Justin Woods · 12/18/2005 (6:42 pm) · 8 comments

Let's start by diving right into the engine.

Open up engine\game\gameConnection.cc and look for the following around line 76:
// first person
mFirstPerson = true;
mUpdateFirstPerson = false;

One variation of that same code may also look like this:
IMPLEMENT_CONOBJECT(GameConnection);
bool GameConnection::mFirstPerson = true
S32 GameConnection::mLagThresholdMS = 0;

Whichever variation you have, just switch "mFirstPerson = false." Using the first example, this will look like the following:
// first person
mFirstPerson = false;   //changed to make 3rd person the default
mUpdateFirstPerson = false;

Recompile. Test your game because now your character should load in 3rd person by default. However, we aren't quite done.


We need to disable that toggle function, because right now the player can still USE first person. If you do NOT intend to completely remove the first person perspective from your game, then you are done.

For the rest of you, open up \client\config.cs and look for the following around line 15:
moveMap.bind(keyboard, "tab", toggleFirstPerson);
Comment it out or map a new function to the tab key.


Lastly we will disable the ability to remap the toggle function.
In \client\scripts\optionDlg.cs, around line 220, comment out the following three lines:
...
$RemapName[$RemapCount] = "Switch 1st/3rd";
$RemapCmd[$RemapCount] = "toggleFirstPerson";
$RemapCount ++;
...

$RemapCount ++; is being used to populate your remap dialouge, so if you don't remove it there will be a big blank line in the remap GUI where "Switch 1st/3rd" used to be.

About the author

Recent Blogs


#1
12/22/2005 (12:45 pm)
Im new to torque, so bare with me, but is there a script variable which can be changed to start in 3rd person, instead of making the code change? Second, if there is no script var, is there a script function that could change this at mission start up?

Thanks, John
#2
12/27/2005 (4:47 am)
John, this resource if for those that want a more "secure" third person view.

If you want a quick way to default into 3rd person without caring if the player can switch back to first person using the TAB key, then do the following:

In game.cs find the function function GameConnection::createPlayer(%this, %spawnPoint)
Now before the player is created, add this:

// Default to 3rd Person View
$firstPerson = false;
ServerConnection.setFirstPerson($firstPerson);

There may be other ways but this works for me.

Nick
#3
12/31/2005 (5:34 pm)
That's one way to do it, and then you can do the \client\config.cs and \client\scripts\optionDlg.cs parts from my tutorial.

I would really suggest that you take the method shown in my tutorial for the more secure version, but Nick's suggestion should work just fine.
#4
01/01/2006 (7:21 am)
Thanks - very handy.
#5
03/09/2006 (6:03 pm)
Thanks Nick Zafiris, just what the doctor ordered.
#6
05/05/2006 (2:44 am)
I couldnt find the engine folder: "engine\game\gameConnection.cc "
I have the 1.4 version and it came with the fps/tutorial/starter folders........I also purhased the rtsstarter.
seems like i have multiple copies of the game engine on my system from each install little confussing since all files are not in one package...

But this worked great fornow when I used it thanx...
// Default to 3rd Person View
$firstPerson = false;
ServerConnection.setFirstPerson($firstPerson);
#7
12/12/2006 (10:06 am)
most excellent, both options fixed my problems totally , nice work guys.
#8
04/13/2007 (10:09 am)
I'm running version 1.5 on a Mac and this didn't quite do it for me. While the first part worked, starting in 3rd person, the unbinding of the tab key didn't take. With 2 presses of the tab key, it was again fully functional and switching the camera back and forth.

Are there other places I need to be looking for key bindings? Why does it seem like the same preferences get set in so many different places?