Game Development Community

Question about path cameras

by Eric Thomas Patton · in Torque 3D Professional · 09/20/2010 (5:11 pm) · 2 replies

Hey guys, I'm working on porting over my old code from TGEA for a project where we are virtualizing a college campus as a substitute for orientation. I had it to where I could spawn a PathCamera into a mission for the main menu and then move the camera to different spots for the different guis.

I'm having an issue porting the code over, however. I have it spawning me in the correct mission, but when I try to create the PathCamera, it throws a syntax error. I have it in the gameCore.cs:

function GameCore::onClientEnterGame(%game, %client)
{
   //echo (%game @"c4 -> "@ %game.class @" -> GameCore::onClientEntergame");
   if($mainMenu)
   {  
      // Create a new camera object.
      
      %client.camera = new Camera()
      {
         dataBlock = Observer;
      }
      
      // Create path camera
      %client.PathCamera = new PathCamera(MainCam) 
      {
         dataBlock = LoopingCam;
         position = "0 0 300 1 0 0 0";
      };
      
      %client.PathCamera.followPath("MissionGroup/MainMenuPath");

      $Server::Client = %client;
      %client.setControlObject(%client.PathCamera);
   }
   else
   {
      // Sync the client's clocks to the server's
      commandToClient(%client, 'SyncClock', $Sim::Time - $Game::StartTime);
   
      // Find a spawn point for the camera
      // This function currently relies on some helper functions defined in
      // core/scripts/server/spawn.cs. For custom spawn behaviors one can either
      // override the properties on the SpawnSphere's or directly override the
      // functions themselves.
      %cameraSpawnPoint = pickCameraSpawnPoint($Game::DefaultCameraSpawnGroups);
      // Spawn a camera for this client using the found %spawnPoint
      %client.spawnCamera(%cameraSpawnPoint);
   
      // Setup game parameters, the onConnect method currently starts
      // everyone with a 0 score.
      %client.score = 0;
      %client.kills = 0;
      %client.deaths = 0;
   
      // weaponHUD
      %client.RefreshWeaponHud(0, "", "");
   
      // Prepare the player object.
      %game.preparePlayer(%client);
   }
}

and here is my code from TGEA that I'm attempting to port over, it is in game/scriptsAndAssets/server/scripts/game.cs:

function GameConnection::onClientEnterGame(%this)
{
   if($mainMenu)
   {   
      commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);

      // Create a new camera object.
      %this.camera = new Camera() 
      {
         dataBlock = Observer;
      };
      MissionCleanup.add( %this.camera );
      %this.camera.scopeToClient(%this);

      // Create path camera
      %this.PathCamera = new PathCamera(MainCam) 
      {
         dataBlock = LoopingCam;
         position = "0 0 300 1 0 0 0";
      };
      %this.PathCamera.followPath("MissionGroup/MainMenuPath");
      MissionCleanup.add( %this.PathCamera);
      %this.PathCamera.scopeToClient(%this);

      $Server::Client = %this;
      %this.setControlObject(%this.PathCamera);
   }
   
   else
   {

      commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);

      // Create a new camera object.
      %this.camera = new Camera() 
      {
         dataBlock = Observer;
      };
      MissionCleanup.add( %this.camera );
      //%this.camera.scopeToClient(%this);

      // Setup game parameters, the onConnect method currently starts
      // everyone with a 0 score.
      %this.score = 0;

      %this.setControlObject(%this.camera);

      %spawnPoint = pickSpawnPoint();
      %this.camera.setTransform( %spawnPoint );
   
      // Create a player object.
      %this.spawnPlayer();
   
   }
   
}

Any help figuring out where I'm going wrong would be most appreciated!

#1
09/24/2010 (12:00 am)
I think you're missing a ; after your Camera object } in GameCore::onClientEnterGame.
#2
09/24/2010 (12:10 am)
Yep, missing semi-colon ending your first new camera declaration.