Game Development Community

Controlling Vehicle and Camera at same time

by Bruce Doh · in Torque Game Engine · 04/16/2007 (2:34 pm) · 7 replies

I've been modifying starter.racing to include a hover vehicle instead of a car, and I am also changing the control scheme. So far, when the mission starts up, the camera orbits the vehicle: %this.camera.setOrbitMode(%this.ship, %this.ship.getTransform(), 0.5, 70, 70);

This allows me to control the camera view with my mouse, which is exactly what I want, although at this point I am unable to control the vehicle. After counting down to the startRace() function, some things are changed:

%cl.lap = 0;
%cl.nextCheck = 1;
%cl.setControlObject(%cl.ship);
%cl.camera.setFlyMode();

But as soon as the setControlObject is called, I can now control the vehicle, although the mouse is now bound to the vehicle, rather than the camera, and I am no longer orbitting, I am either in first person, or a VERY close 3rd person view.

How would I be able to maintain control of the camera with the mouse, while also controlling the vehicle with the keyboard?

#1
04/16/2007 (2:48 pm)
Most likely by implementing the Advanced Camera resource and extending it.
#2
04/16/2007 (2:59 pm)
Ah, so I will have to do some editing of the engine itself? As I mentioned, I already had the camera view I wanted (orbit), just not while I was controlling the vehicle. Will the advanced camera resource allow me to control both at the same time, or should I be able to do it without? (if I understand correctly, the advanced camera resource simply adds more views, and since I already have the view I want, I shouldn't need that addon... correct?)
#3
04/16/2007 (11:59 pm)
Well, now I've implemented the advanced camera control, and I have the new camera in place. I have removed any bindings to the mouse and reassigned them to the X-axis = rotateCameraHorizontal and Y-axis = rotateCameraVertical functions (in both config.cs and default.bind.cs). The functions are defined as follows:

function rotateCameraHorizontal(%val)
{
$advCamera::Yaw = getMouseAdjustAmount(%val)*$cameraYawSpeed ;

}

function rotateCameraVertical(%val)
{
$advCamera::Pitch = getMouseAdjustAmount(%val)*$cameraPitchSpeed;
}

Yet for some reason, the camera still follows the direction of the vehicle, and moving the mouse does not change the view. I put an echo statement in one of the functions to make sure it was being executed, and sure enough, it is being run, but the camera is not changing. Any insight into why this isn't working?
#4
04/23/2007 (3:26 pm)
So nobody can help me with the camera? It seems like such a simple thing to do. I must just be missing something silly...
#5
04/27/2007 (3:47 pm)
Problem solved. I'm not sure what was wrong before, but I started from scratch and everything worked out fine!
#6
06/28/2007 (11:07 am)
Hi Bruce,
Could you give a hint as how you did it ?
I am running into the same problem.
Thanks.
#7
06/28/2007 (12:15 pm)
Sorry, but I can't really elaborate other than the fact that I implemented the advanced camera control. I'm not sure what I was doing wrong, but after starting from scratch I got it to work.