Game Development Community

How to move camera in a fixed path

by Googole · in Torque Developer Network · 09/22/2009 (6:16 am) · 1 replies

I read many articles and they really help me a lot. But i am a newbie to TGE , i still meet problems.

I am coding a game, when game starts, i want to move the camera around the arena, to preview the arena.

What i have done is:

1 Setup PathCamera in onClientEnterGame:
// Create path camera
%this.PathCamera = new PathCamera() {
dataBlock = MyPathCamera;
position = "0 0 300 1 0 0";
};

%this.PathCamera.followPath("MissionGroup/CameraPath");
%this.schedule(6500, "MissionCleanup.add", %this.player);
%this.schedule(7000, "setControlObject", %this.player);

MissionCleanup.add( %this.PathCamera );
%this.PathCamera.scopeToClient(%this);
$Server::Client = %this;
%this.setControlObject(%this.PathCamera);

2 In mission file, i add this path:

new Path(CameraPath) {
type = "3";

new Marker(0) {
//position = "98.5565 -59.2192 155.86";
position = "-788.137 -319.431 5.8";
rotation = "0 0 1 138.083";
Scale = "1 1 1";
seqNum = "0";
msToNext = "10000";
};
new Marker(1) {
//position = "549.357 -619.466 126.362";
position = "-686 -368 5";
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";
};
};

3 PathCamera.cs
datablock PathCameraData( MyPathCamera )
{
mode = "";
};

function MyPathCamera::onAdd(%this, %obj)
{
echo("MyPathCamera::onAdd");
}

function MyPathCamera::onNode(%this, %camera, %node)
{
echo("MyPathCamera::onNode");
}

function PathCamera::followPath(%this, %path)
{
%this.path = %path;

if (!(%this.speed = %path.speed))
%this.speed = 100;

if (%path.isLooping)
%this.loopNode = %path.getCount() - 2;
else
%this.loopNode = -1;

%this.pushPath(%path);
%this.popFront();
}

function PathCamera::pushPath(%this, %path)
{
for (%i = 0; %i < %path.getCount(); %i++)
%this.pushNode(%path.getObject(%i));
}

function PathCamera::pushNode(%this, %node)
{
if (!(%speed = %node.speed))
%speed = %this.speed;

if ((%type = %node.type) $= "")
%type = "Normal";

if ((%smoothing = %node.smoothingType) $= "")
%smoothing = "Linear";

%this.pushBack(%node.getTransform(), %speed, %type, %smoothing);
}

function PathCamera::moveToNode(%this, %path, %index)
{
echo ("DBD PathCamera::moveToNode");
%this.path = %path;
%this.currentNode = %index;
%node = %this.path.getObject(%index);
%this.pushBack(%node.getTransform(), 10, "Normal", "Spline");
}

4 in my "man down" game, i add this at the previewing time(in Python):
manDownPlayer = DBEObject(id)
gameConn = manDownPlayer.getControllingClient()
pathCamera = DBEObject(gameConn).PathCamera
DBEObject(pathCamera).moveToNode(DBEObject("CameraPath"), 1)


all these pass compilation, but i still get no visual effect. Can anybody tell me where i make it wrong ...?

What should i do at calling side?

Thanks all

#1
09/22/2009 (7:02 am)
I can't help you with your path camera specifically, but have you looked at the torque demo? It uses a pathed camera to take you thru the game world to see all the interesting things there.