Remove 1st person view
by fiveforty · in Torque Game Engine · 10/24/2005 (9:39 am) · 22 replies
Hi, can someone tell me how to rid of the first person view in starter.racing?
if it is possible that is
basically I want it so the player will always be viewing in 3rd person mode
I know tht you can toggle between 1st and 3rd with the tab key, but I want to get rid of the 1st person view altogether
I've looked through the various different files, but seeing as I'm a newb I'm not 100% certain what I'm looking for
can anybody help or at least point me in the right direction??
if it is possible that is
basically I want it so the player will always be viewing in 3rd person mode
I know tht you can toggle between 1st and 3rd with the tab key, but I want to get rid of the 1st person view altogether
I've looked through the various different files, but seeing as I'm a newb I'm not 100% certain what I'm looking for
can anybody help or at least point me in the right direction??
About the author
#2
10/24/2005 (10:40 am)
From one newb to another, if your interested in using your question as a jumping point to learn a little about the workings of the engine, you could check out the .h and .cc files for wheeledVehicle, vehicle, player, and shapeBase. There are some interesting members and methods like renderFirstPerson and isFirstPerson. Just ctrl+f "person". I can't say that I fully understand everything there myself, but it kinda gives you an inkling of some of the available functionality, and later on you'll have a problem and go, "I seem to remember seeing that..." :)
#3
set that somwhere... and disable whatever the tab button does.
10/24/2005 (11:19 am)
$firstperson=0;set that somwhere... and disable whatever the tab button does.
#4
the problem with that is that ym demo starts in 1st person mode so deleting it means I'm suck like it and cant change to 3rd person
it would be ok if I could get it to start in 3rd person view all the time
@Noah:
I've looked through all of those suggested files, there is loads of intresting stuff in there, but I cant really see what I would need to change
@Ramen:
what file would I have to set that in??
10/25/2005 (3:10 am)
@Rubes:the problem with that is that ym demo starts in 1st person mode so deleting it means I'm suck like it and cant change to 3rd person
it would be ok if I could get it to start in 3rd person view all the time
@Noah:
I've looked through all of those suggested files, there is loads of intresting stuff in there, but I cant really see what I would need to change
@Ramen:
what file would I have to set that in??
#5
12/13/2005 (12:42 am)
I also want to accomplish this, did anyone ever figure it out?
#6
What you need to do is go to your server/scripts/game.cs file & at around line 127 find this function:
Near the end of the function just before the second to last closing brace } add this:
The whole thing should look like this:
That's it, now when the game starts & the countdown finishes you will be in 3rd person view. Also the tab key will still switch between first & third person views.
12/13/2005 (4:41 am)
Hey guys, this isn't that hard. What you need to do is go to your server/scripts/game.cs file & at around line 127 find this function:
function startRace()
Near the end of the function just before the second to last closing brace } add this:
toggleFirstPerson(1);
The whole thing should look like this:
function startRace()
{
// Inform the client we're starting up
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
%cl = ClientGroup.getObject( %clientIndex );
commandToClient(%cl, 'GameStart');
// Other client specific setup..
%cl.lap = 0;
%cl.nextCheck = 1;
%cl.setControlObject(%cl.car);
%cl.camera.setFlyMode();
[b]toggleFirstPerson(1);[/b]
}
// Start the game timer
// if ($Game::Duration)
// $Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd" );
$Game::Running = true;
$Game::Running = true;
}That's it, now when the game starts & the countdown finishes you will be in 3rd person view. Also the tab key will still switch between first & third person views.
#7
T.
12/13/2005 (7:50 am)
No, you cant call toggleFirstPerson() there. startRace() runs on the server and toggleFirstPerson() is a client function. That will work only for the host of the game. You need to find a server side solution, which would be to setup the camera correctly when you create it. You'd have to dig into the code to find out exactly how it should be done because I cant remember off hand :)T.
#8
12/13/2005 (8:03 am)
No one said anything about networks. Besides, not trying to sound rude but it works fine both single & multiplayer. I have tested both, not over internet but across lan. So it does work & can be placed there, try it.
#9
First, follow server/scripts/game.cs and you'll see a call gets made to client/script/game.cs (I think that's the structure, I'm doing this from memory).
Inside client/scripts/game.cs is a startGame() function (or some such naming convention) that is explicitly called immediately prior to startup.
Within this function, simply call toggleFirstPerson(1);
Now, use your script editors' search feature to locate every instance of toggleFirstPerson() and/ or $firstPerson.
You're going to find that there are about 3 or 4 places where this function is bound to the tab key. Comment them out.
Now you'll start in 3rd person AND stay in third person (you just disabled the toggle).
The only thing left t do, assuming you're wanting thrid person perspective ONLY, is to remove the ability to remap that function to a key in the remap dialog... haven't done that yet, but if you're interested I can post when I get around to it and let you know how.
12/13/2005 (8:10 am)
I just did this last night...First, follow server/scripts/game.cs and you'll see a call gets made to client/script/game.cs (I think that's the structure, I'm doing this from memory).
Inside client/scripts/game.cs is a startGame() function (or some such naming convention) that is explicitly called immediately prior to startup.
Within this function, simply call toggleFirstPerson(1);
Now, use your script editors' search feature to locate every instance of toggleFirstPerson() and/ or $firstPerson.
You're going to find that there are about 3 or 4 places where this function is bound to the tab key. Comment them out.
Now you'll start in 3rd person AND stay in third person (you just disabled the toggle).
The only thing left t do, assuming you're wanting thrid person perspective ONLY, is to remove the ability to remap that function to a key in the remap dialog... haven't done that yet, but if you're interested I can post when I get around to it and let you know how.
#10
12/13/2005 (12:05 pm)
I for one would be interested. Thank you in advance.
#11
Also, how would I accomplish the same thing in the First Person Shooter demo? Tab does the same thing, moving from first to third person. I want my game to exlusively be in third person.
12/13/2005 (1:29 pm)
I would also be interested. Thanks.Also, how would I accomplish the same thing in the First Person Shooter demo? Tab does the same thing, moving from first to third person. I want my game to exlusively be in third person.
#12
I plan to sit down and rip the remap out of the options dialog tonight. I'll post the fix when I finish.
12/13/2005 (1:44 pm)
Same way. You'll find that many f the scripts are simpyl duplicates with subtle changes here and there. There's no difference between limiting the camera in starter.FPS, starter.Racing, tutorial.Base or a custom directory you build yourself.I plan to sit down and rip the remap out of the options dialog tonight. I'll post the fix when I finish.
#13
If you want to prevent people binding toggleFirstPerson to a key, you could simply comment the function out of default.bind.cs. If you really want to make sure, you could go into the setFirstPerson function in the engine and change it so that it won't set the engine variable to first person.
I haven't tested this, but I'm pretty sure it should work.
12/13/2005 (2:03 pm)
The function "toggleFirstPerson" is defined in client/scripts/default.bind.cs and appears to be a simple toggle. That is, it changes the state from one to the other. Since you want to set a specific state, you would do better to call "ServerConnection.setFirstPerson(false);", which is what toggleFirstPerson does anyway.If you want to prevent people binding toggleFirstPerson to a key, you could simply comment the function out of default.bind.cs. If you really want to make sure, you could go into the setFirstPerson function in the engine and change it so that it won't set the engine variable to first person.
I haven't tested this, but I'm pretty sure it should work.
#14
For now, this does all I need it to. I'll refine it all later. (C;
12/13/2005 (2:07 pm)
Yes, I had hard coded the change in a previous version of the enginge, I know it can be done - just hadn't bothered yet.For now, this does all I need it to. I'll refine it all later. (C;
#15
There are only three lines of script you need to remove to disable the ability to remap the toggle function.
In client/scripts/optionDlg.cs, around line 220, comment out the following three lines:
The $RemapCount ++; line is only being used to populate the remap dialogue, you don't have to remove it to disable the remap, but it leaves an ugly blank line in your dialog if you don't.
Easy cheesy. (C;
12/13/2005 (5:36 pm)
Okay then...There are only three lines of script you need to remove to 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 ++; ...
The $RemapCount ++; line is only being used to populate the remap dialogue, you don't have to remove it to disable the remap, but it leaves an ugly blank line in your dialog if you don't.
Easy cheesy. (C;
#16
First, remove the command to toggleFirstPerson() you put in client/scripts/game.cs if you did so previously.
We won't be needing that anymore and it's really just a hack anyway.
Now open up you compiler and open the Torque project.
Open up sourceFiles/ game/ gameConnection.cc and look for the following around line 76:
Change it to:
and recompile the engine.
It's that easy... I've just been to lazy to recomile lately. (C;
12/13/2005 (5:47 pm)
I thought I'd also adress cleaning up the solution here and implementing a more permanent fix without all the ugly script hacking.First, remove the command to toggleFirstPerson() you put in client/scripts/game.cs if you did so previously.
We won't be needing that anymore and it's really just a hack anyway.
Now open up you compiler and open the Torque project.
Open up sourceFiles/ game/ gameConnection.cc and look for the following around line 76:
// first person mFirstPerson = true; mUpdateFirstPerson = false;
Change it to:
// first person mFirstPerson = false; //changed to make 3rd person the default mUpdateFirstPerson = false;
and recompile the engine.
It's that easy... I've just been to lazy to recomile lately. (C;
#17
12/13/2005 (5:48 pm)
@Kirby, Thank you, the engine code version worked like a charm in starter.fps.
#18
The engine defaults to the first person view, so you have two options:
1) Implement the code change I listed above - this basically sets the view to thrid person right after a connection to the game is established.
2) in client/ scripts/ game.cs, find the following function:
and modify it to this:
With option 2, you'll have to be sure to eliminate each and every call that binds the Tab key to the toggleFirstPerson() fucntion and alter your remap dialog.
~ Hope that helps.
12/13/2005 (6:41 pm)
I see what you mean.The engine defaults to the first person view, so you have two options:
1) Implement the code change I listed above - this basically sets the view to thrid person right after a connection to the game is established.
2) in client/ scripts/ game.cs, find the following function:
function clientCmdGameStart(%seq)
{
PlayerListGui.zeroScores();
}and modify it to this:
function clientCmdGameStart(%seq)
{
toggleFirstPerson(1);
PlayerListGui.zeroScores();
}With option 2, you'll have to be sure to eliminate each and every call that binds the Tab key to the toggleFirstPerson() fucntion and alter your remap dialog.
~ Hope that helps.
#19
However, this will only default you to third person. You still need to kill the key bind to diable the toggle if you want that option.
Thank you very much Kirby, a combination of the methods worked perfectly. One of the most flawless changes in Torque so far.
Would you mind if I posted this as a resource?
12/13/2005 (7:00 pm)
@Kirby Actually I edited my post right up there, thanking you because the engine code version works fine. I was just hung up on trying to use your script hack before that.However, this will only default you to third person. You still need to kill the key bind to diable the toggle if you want that option.
Thank you very much Kirby, a combination of the methods worked perfectly. One of the most flawless changes in Torque so far.
Would you mind if I posted this as a resource?
#20
12/14/2005 (6:52 am)
Not at all. Have at it. (C:
Torque 3D Owner Rubes
Go to the file /starter.racing/client/config.cs
and find the line:
moveMap.bind(keyboard, "tab", toggleFirstPerson);
you can probably just delete the line.