Blockland Forums > Modification Help
PathCamera
WRB852:
When I try to create a PathCamera, it gives me this error:
--- Code: ---==>new PathCamera();
<input> (0): Register object failed for object (null) of class PathCamera.
--- End code ---
Anyone know what I'm doing wrong?
otto-san:
probably because you specified absolutely nothing about the object
...
Chrono:
No datablock.
WRB852:
edit: i figured it out
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: ---//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);
}
--- End code ---
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?