Game Development Community

Help using Path Camera on a spawn point

by Jose M Euvin · in Torque Game Engine · 03/30/2012 (7:10 am) · 1 replies

Here is my problem, I'm trying to implement a PathCamera in my game. I'm not getting any errors in the console, but the damn thing is not doing anything.



This piece of code was added in core/art/datablocks/camera.cs

First:

//new path cam datablock
datablock PathCameraData(CamPath)
{
};

I then add this portion of code in my mission file.

new SimGroup(Paths)  
{  
  new Path(CameraPathModel) {  
      isLooping = "1";  
      canSave = "1";  
      canSaveDynamicFields = "1";  
      
      new Marker() {  
         seqNum = "1";  
         type = "Normal";  
         msToNext = "1000";  
         smoothingType = "Linear";  
         position = "-25.0275 -11.5198 1.51868";  
         rotation = "1 0 0 0";  
         scale = "1 1 1";  
         canSave = "1";  
         canSaveDynamicFields = "1";  
         speed = "5";  
      };  
      new Marker() {  
         seqNum = "2";  
         type = "Normal";  
         msToNext = "1000";  
         smoothingType = "Linear";  
         position = "-25.0275 -12.5198 1.51868";  
         rotation = "1 0 0 0";  
         scale = "1 1 1";  
         canSave = "1";  
         canSaveDynamicFields = "1";  
         speed = "5";  
      };  
      new Marker() {  
         seqNum = "3";  
         type = "Normal";  
         msToNext = "1000";  
         smoothingType = "Linear";  
         position = "-25.0275 -13.5198 1.51868";  
         rotation = "1 0 0 0";  
         scale = "1 1 1";  
         canSave = "1";  
         canSaveDynamicFields = "1";  
         speed = "5";  
      };  
  };  
};

Then:
I created pathCam.cs and added the following. I'm also executing it this file in /scripts/client/init.cs

$Camera = localclientconnection.camera;  

function testPathCamera()    
{    
    %p = createCameraPath(CameraPathModel); 
    //saves our current camera  
    $savecamera = localclientconnection.camera; 
    //replace our current camera with our path camera
    localclientconnection.camera = %p;  
    //binds the camerea to our new path camera
    LocalClientConnection.setControlObject(localclientconnection.camera);
    //moves the path camerea to our targt position  
     
     if(isObject(CameraPathModel))
         setPathCamera(CameraPathModel);       
}    

function setPathCamera(%path)
{
   for(%i = 0; %i <%path.getCount(); %i++)
      localclientconnection.camera.setTarget(%i); 
}
        
function cleanTestPathCamera()    
{    
    $Camera.delete();    
    $Camera = $savecamera;    
    localclientconnection.setControlObject($Camera);    
}    
        
function createCameraFollowPath(%path,%name)    
{    
    if( isObject(%path) && %path.getCount())    
    {    
       %pathNode = %path.getObject(0);    
       %transform = %pathNode.getTransform();    
       %pos = getWords( %transform, 0 ,2 );    
       %rot = getWords( %transform, 3 ,6 );    
        
       %p = new PathCamera(myPath) {    
            dataBlock = CamPath;    
            position = %pos;    
            rotation = %rot;    
       };    
                
    for(%i = 1; %i < %path.getCount(); %i++)    
    {    
        %pathNode = %path.getObject(%i);    
        %transform = %pathNode.getTransform();    
        %p.pushBack(%transform,2,"Normal","Spline");    
    }    
                
     return %p;    
    }    
}

When I test my function in the console i type in setPathCamera(myPath) and nothing happens.

After I reset by typing in cleanTestPathCamera the camera moves to the spawnpoint and returns to the previous camera mode. I also try using:

I even try using $Camera.setTarget(1), 2, 3 etc...

myPath.setTarget(0.1), 0.2, 0.3 etc

and $Camera.setTarget(0.1), 0.2, 0.3 etc

Not sure what I'm missing, someone please help.

Thank you.