Game Development Community

dev|Pro Game Development Curriculum

Camera moving along path

by Frank Bignone · 12/13/2002 (3:08 pm) · 12 comments

Download Code File

Here is a small code snipset to add pathed camera that will follow a path in the game (useful for cute-scene and intro). This code is based on my previous contribution with dynamic shape moving along path(Object moving along path). You should install it before changing your camera.cc & camera.h source with the ones available in the archive file.

Then you will can use the following script command to set the camera to followMode :
camera.setFollowMode(pathId, <ticksynchro>);

Here is a working example that we used in DoP to have a view of the map during player selection (useful for race mode in order to show the complete map).

In the mission file, add a group named like that
new Path(FollowCam) {
      type = "3";

      new Marker(0) {
         position = "98.5565 -59.2192 145.86";
         rotation = "0 0 1 138.083";
         Scale = "1 1 1";
         seqNum = "0";
         msToNext = "10000";
      };
      new Marker(1) {
         position = "549.357 -619.466 116.362";
         rotation = "0 0 -1 111.909";
         Scale = "1 1 1";
         seqNum = "1";
         msToNext = "10000";
      };
      new Marker(2) {
         position = "116.233 -79.7992 147.749";
         rotation = "0 0 -1 43.7272";
         Scale = "1 1 1";
         seqNum = "2";
         msToNext = "10000";
      };
      new Marker(3) {
         position = "-66.688 432.816 140.754";
         rotation = "0 0 -1 68.9373";
         Scale = "1 1 1";
         seqNum = "3";
         msToNext = "10000";
      };
   };

and in the OnClientEnterGame, add the following bit of code at the end of the function
%path = findMissionObject( "Path", "FollowCam" );
   if( !isObject(%path) ) {
       error("[onClientEnterGame] Cannot find path " @ %pathGroup );
   }
   else {
        // Get path id
        %pathId = %path.getIndex();
        %this.camera.setFollowMode(%pathId);
        echo("Set follow mode for camera");
   }

About the author

Real programmers don't waste time recompiling; they patch the binary files... ... Real programmers don't waste time patching binary files; they patch memory.


#1
12/08/2002 (1:49 am)
Works like a charm!! Thanks a lot! :)
#2
12/08/2002 (11:46 pm)
Excellent ! Thank really much !
#3
12/09/2002 (8:21 pm)
Link is bad.
#4
12/09/2002 (11:30 pm)
It's because the resource is not approven yet. You can download it here if you want Download section
#5
12/15/2004 (4:28 pm)
This resource seems not current for 1.3 TGE source.
#6
03/04/2005 (6:12 pm)
Is this still a valid resource or had there been a better way of doing this?

Toby.
#7
11/25/2005 (12:52 pm)
Very nice! Saves me some work from digging thru the demo scripts :)
Thanks!
#8
05/27/2006 (11:14 pm)
I cant get this to work with 1.4.

I get compilation errors all pointing at the camera.cc and camera.h files in the resource.

I dont understand, why do we need to modify the engine when the demo has managed to integrate a camera moving along a path, cant we just implement the same scripts that the demo has?

Regards
#9
05/29/2006 (12:24 am)
This feature was added in old release of TGE that did not support dynamic path for camera. You should not use it on new release of TGE and use instead the provided code of TGE.
#10
06/13/2008 (7:27 am)
Hi! i have an error it says unable to find function, findmissionobject
#11
06/13/2008 (7:29 am)
and a question how can i "import" the camera.cc and camera.h in the game or the engine
#12
11/04/2010 (10:50 pm)
Hi, I'm a N00b. Is there a way to do this on torque 3D?

I tryed just copying the script and the console throws "scripts/server/gameCore.cs (457): Unable to find function findMissionObject".

Thanks.