How to use PathCamera?
by Nicolas Tian · in Torque Game Engine · 06/05/2005 (12:43 pm) · 0 replies
Sorry I'm a absolute newbie, I just tried to use PathCamera, but it didn't work, can anyone tell me why?
Here is my pathCamera.cs (I modified it from pathShape.cs):
Then I modified the function onClientEnterGame:
When I ran the demo, nothing happened! Can anybody help me with this? I really appreciate your help! Thanks a lot!
Here is my pathCamera.cs (I modified it from pathShape.cs):
datablock PathCameraData( MyPathCamera )
{
mode = "";
};
function MyPathCamera::onAdd(%this, %obj)
{
}
function MyPathCamera::onNode(%this, %camera, %node)
{
}
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.smoothing) $= "")
%smoothing = "Linear";
%this.pushBack(%node.getTransform(), %speed, %type, %smoothing);
}Then I modified the function onClientEnterGame:
function GameConnection::onClientEnterGame(%this)
{
// Every client get's a camera object.
%this.camera = new PathCamera()
{
dataBlock = MyPathCamera;
};
%this.camera.followPath("MissionGroup/CameraPath");
MissionCleanup.add( %this.camera );
%this.camera.scopeToClient(%this);
// Create a player object.
%spawnPoint = pickSpawnPoint();
%this.createPlayer(%spawnPoint);
}When I ran the demo, nothing happened! Can anybody help me with this? I really appreciate your help! Thanks a lot!