Game Development Community

Problem with toggleFirstPerson

by Iv · in Torque Game Engine · 11/26/2005 (10:12 am) · 12 replies

First of all, let me give you a brief intro on me:

I'm a coder (C/C++/Java) since about 10 years, i just took the decision of trying to code
some 3d game ideas i'm having in mind. So i took torque as it seemed the best solution
to start with.

Messing a little with the script language i found something strange. As a start point I took
trq_tutorial_base. After playing a little with the environment itself i just decided to use
that as the skeletal for what im trying to do. So my first step was taking rid of the compiled
engine that came with the example substituting it for a fresh compiled v14 version.

Everything worked as expected but the toggleFirstPerson function is doing nothing, while
it did proper with the example shipped engine. I just took a look at the client\default.bind.cs
and found the function, just decided to add an "echo" there to see if i was reaching that code
or it was just input not being recognised.

function toggleFirstPerson(%val)
{
   if (%val)
      $firstPerson = !$firstPerson;
   
      echo("Changing camera, received param: " @ %val );
}

The output result was the same with both engines. Further ahead i thought that i should
be looking in server scripts for that "$firstPerson" variable and check how it was to be handled.
But i had no luck, couldn't find it anywhere besides on this "default.bind.cs".

So can you give me any hint on this?

Thank you very much in advance!

About the author

Recent Threads


#1
11/26/2005 (10:24 am)
Wow. i had something similiar happen. My GUI items would not behave properly with my built exe. I upgraded to the latest service pack to fix that.


And whith the toggle first person... i had a similiar issue with that. after compiling 1.4, i copied over my existing project files and it would not call toggle first person via the tab button. I ended up having to start with an existing default.binds and simply add in the new functions i had.
#2
11/26/2005 (10:32 am)
And could you make the 3rd person cam work by some extra scripting at last?, if so i'd love to know how ;)
#3
11/26/2005 (10:44 am)
I'm not sure what was up with my default.bind file. it works just fine with 1.3, but when i copied it over for my new 1.4 project, it wouldn't call it no matter how many times i pressed tab. I ended up taking that default.bind from starter.fps and copied it over my existing one. then added what i needed.

Have you tried opening the console and typing

toggleFirstPerson(1)


?
#4
11/26/2005 (11:14 am)
I just tried that and it's not working, i believe there is no problem with the tab key being bind as long as i can get my "echoes" when i press it, it maybe related to some inner change in the engine. Anyway im just trying the advanced camera. Btw i just saw your comment for v14 there, so nice :)
#5
11/26/2005 (11:23 am)
Yeah, it works just fine as long as you add in any code changes that are listed past march 3rd. there doesn't seem to be any issues with jitter with 1.4 that were there with 1.3.
#6
11/26/2005 (11:57 am)
If you look at the 1.4 version of toggleFirstPerson you will see that its different from the 1.3 version.

there is an added command

This is what my 1.4 looks like for toggleFirstPerson

$firstPerson = true;
function toggleFirstPerson(%val)
{
   if (%val)
   {
      $firstPerson = !$firstPerson;
      [b]ServerConnection.setFirstPerson($firstPerson);[/b]
   }
}

I bolded the added command, if your missing this in yours then toggleFirstPerson does not work properly for 1.4.
#7
11/26/2005 (12:05 pm)
That would be why mine didn't work. thanks
#8
11/26/2005 (12:57 pm)
That actually worked, thank you very much Simon!

But still cant make the advCamera to work on v14 (based on the trq_tutorial_base) , i have no errorMessages at all and I
followed all the scripting steps religiously. It's
#9
11/26/2005 (1:13 pm)
Further on, executing clientgroup.getObject(0).advCamera.setOrbitMode(); in console works, without an error. But produces no output, im guessing the problem is that the client is still showing me the standard camera instead the advanced one. I'll try to remove any reference to the standard cam, and see the results....
#10
11/26/2005 (1:50 pm)
OK, well it looks like it's working in script. are you pressing tab to go into the advanced camera? by default it will start you off in first person view.

The advanced camera exists separately fromt he standard camera.


I added this in after setting up the camera in ::createplayer

$firstPerson =0;
ServerConnection.setFirstPerson($firstPerson);
#11
11/26/2005 (2:07 pm)
Yeah, thanks!!! that was it :), thanks a lot. Now its all working... (all the views) however this binds:

$cameraYawSpeed = -100.0;
$cameraPitchSpeed = -50.0;
$cameraZoomSpeed = -5.0;

function rotateCameraHorizontal(%val)
{
     $advCamera::Yaw = getMouseAdjustAmount(%val)*$cameraYawSpeed ;
     echo( "Rotating hor" @ %val );
}

function rotateCameraVertical(%val)
{
     $advCamera::Pitch = getMouseAdjustAmount(%val)*$cameraPitchSpeed;
     echo( "Rotating ver" @ %val );
}

function zoomCamera(%val)
{
     $advCamera::Zoom = getMouseAdjustAmount(%val)*$cameraZoomSpeed;
}

moveMap.bind( mouse, xaxis, rotateCameraHorizontal);
moveMap.bind( mouse, yaxis, rotateCameraVertical );
moveMap.bind( mouse, zaxis, zoomCamera );

doesn't work at all :/, i have to let the standard ones running. And i cant use the zoom at all :S

Im sorry to bother you that much, but im guessing you've already run through what im trying...
Any hint with this? ;)
#12
11/26/2005 (2:33 pm)
Forget about the last post, now i just noticed that those binds are for orbit and static cams, not for a 3rd person and it makes sense that way. Excuse my newbiness, im working on it. And thanks again for all the help!!!