Author Topic: PathCamera  (Read 1668 times)

When I try to create a PathCamera, it gives me this error:

Code: [Select]
==>new PathCamera();
<input> (0): Register object failed for object (null) of class PathCamera.

Anyone know what I'm doing wrong?

probably because you specified absolutely nothing about the object

...


edit: i figured it out
« Last Edit: July 14, 2010, 04:30:00 PM by WRB852 »

Alright, I simply can't figure out this whole PathCamera thing. Does anyone have any idea how to use it? Here's my script so far:

Code: [Select]
//item_camcorder.cs

datablock PathCameraData(pathCamData)
{
newField = "Blank";
};

package pathCameraPackage
{
function GameConnection::onClientEnterGame(%this)
{
%this.pathCamera = new pathCamera()
{
datablock = "pathCamData";
class = "PathCamera";
};
%this.pathCamera.popFront();
Parent::onClientEnterGame(%this);
}
};

activatePackage(pathCameraPackage);

//////////
// item //
//////////

datablock ItemData(Camcorder)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./camcorder.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "Camcorder";
iconName = "./icon_camcorder";
doColorShift = true;
colorShiftColor = "1.0 1.0 1.0 1.0";

// Dynamic properties defined by the scripts
image = camcorderImage;
canDrop = true;
};

datablock ShapeBaseImageData(camcorderImage)
{
   shapeFile = "./camcorder.dts";
   emap = true;

   mountPoint = 0;
   offset = "0 0 0";
   eyeoffset = "0.0 0.0 20.0";
   rotation = eulerToMatrix( "0 0 0" );
 
   correctMuzzleVector = true;

   className = "WeaponImage";

   item = Camcorder;
   ammo = " ";
   projectile = " ";
   projectileType = " ";

   melee = false;
   //raise your arm up or not
   armReady = true;

   doColorShift = true;
   colorShiftColor = Camcorder.colorShiftColor;//"0.400 0.196 0 1.000";

stateName[0]                      = "Activate";
stateTimeoutValue[0]              = 0.0;
stateTransitionOnTimeout[0]      = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1]                      = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]          = true;
stateSequence[1] = "Ready";

stateName[2]                    = "Fire";
stateFire[2]                    = true;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateTransitionOnTriggerUp[2]    = "Ready";

};

function camcorderImage::onFire(%this,%obj,%slot)
{
%timesFired = 0;
%transform = %obj.gettransform();
%a = 1;
%b = "normal";
%c = "spline";
%timesFired++;
if(%timesFired <= 1)
{
%obj.client.pathcamera.pushFront(%transform,%a,%b,%c);
} else {
%obj.client.pathcamera.pushBack(%transform,%a,%b,%c);
}
}

function ServerCmdpathCameraStart(%client)
{
%client.pathcamera.setPosition(0.0);
%client.pathcamera.setState("forward");
%client.pathcamera.setTarget(1.0);
%client.setcontrolobject(%client.pathcamera);
}

function ServerCmdpathCameraEnd(%client)
{
%client.setcontrolobject(%client.camera);
}

If you don't know much about them, you can read about them on page 96 of this PDF.

First it creates a PathCamera on each client when they join the server. Then when you pick up the camcorder and fire it, it adds knots to the PathCamera. Then after that, when you do /pathcamerastart for some reason, it sends your camera out into the middle of nowhere. I've tried fiddling with the functions, and I just can't figure it out. Anyone know what's happening?

I used path cameras in the camera events. However it took long to even get them to go into the right position. I have no idea how to move them.

PathCamera's are for TGEA, TGE has the datablock but doesn't have an functions that it should. I already researching into using these things.

PathCamera's are for TGEA, TGE has the datablock but doesn't have an functions that it should. I already researching into using these things.

They work fine in TGE.

=( Mmmk dont listen to me

Cool, so no one knows how to use them! :D

I once had a test map trying to use them for a "plane landing" sequence but I can't find it now...

EDIT: aha, found some of the code. It might help a little.

Code: [Select]
datablock PathCameraData(PathObserver : Observer)
{
   somefield = 1;
};
Making it a copy of Observer even though Observer is a 'normal' camera datablock works. I have to set at least one field otherwise syntax errors come up.

Code: [Select]
%client.camera.delete();
%client.camera = new PathCamera()
{
   datablock = PathObserver;
   position = %client.player.getPosition();
   rotation = "0 0 1 0";
};
%client.setControlObject(%client.camera);
Replaces a set client's 'camera' with a PathCamera. This particular one was for some kind of 'single player' mode that never worked out so using F8 was disabled anyway, but you might want a better solution to store a PathCamera and a normal Camera at the same time.

Code: [Select]
%client.camera.setTransform("392.5 -819.5 74 0.115759 0.212569 0.970265 4.11377");
%client.camera.pushBack(AICamera.getPosition() SPC eulerToAxis("26 0 125"),50 ,"Normal","Linear");
%client.camera.pushBack("387.5 -820.5 75" SPC eulerToAxis("20 0 115"),1 ,"Normal","Linear");
Giving it a start position and rotation, then a set path to move along.
« Last Edit: July 16, 2010, 02:48:27 AM by Space Guy »

I tried doing what you said, and I'm still being sent out into the middle of nowhere. Maybe I could send you it, and you could see what's maybe wrong first hand?

Well, the setTransform is a completely arbitrary position related to the map I had. Don't just copy-paste everything in my post, it won't work like that.

No, I definitely didn't do that. I'm not a complete idiot!

Here's what I have:

Code: [Select]
function camcorderImage::onFire(%this,%obj,%slot)
{
%transform = %obj.gettransform();
%a = 1;
%b = "normal";
%c = "spline";
%obj.timesFired += %a;
echo(%obj.timesFired);
if(%obj.timesFired = 1)
{
%obj.client.pathcamera.setTransform(%transform);
%obj.client.pathcamera.pushBack(%transform,%a,%b,%c);
} else {
%obj.client.pathcamera.pushBack(%transform,%a,%b,%c);
}
}

function ServerCmdpathCameraStart(%client)
{
%client.pathcamera.setPosition(0.0);
%client.pathcamera.setTarget(1.0);
%client.pathcamera.setState("forward");
%client.setcontrolobject(%client.pathcamera);
}

function ServerCmdpathCameraEnd(%client)
{
%client.setcontrolobject(%client.camera);
}
From my understanding, it should start at where I first fired the tool, and then travel along the path of where I fired after that. For some reason, it still takes me out in space.

I would also like to see a working version of this, I tinkered around for about a hour trying to figure out how it works, I had the same results as WRB852.