Game Development Community

Animating doors

by Camel Taylor · in Torque Game Engine · 12/27/2005 (7:16 pm) · 2 replies

Hello I have a quick question about TSStatic. In Advanced 3d programming all in one, I have been stuck on the swinging door example for quite some time that it gives. Now for what I manage to gather about datablock's, TSStatic is only good for an object that is going to be a lump with no player interactions, I think of it as maybe I use it to define some boulders that block the way of a path and I need to go preform a specific task before calling delete on the object. A door however needs to be interacted with and should use StaticShapedata(). Now that sounds fine when I read it but in the example I place the door into the project via the editor and its function adoor::onadd is suppose to be called automaticly and set some stuff up, but here is were everything falls threw If I try to actiavate the door i get


tutorial.base/server/doors.cs (0): Unknown command getDataBlock
object(1697) TSStatic -> SceneObject -> NetObject -> SimObject
tutorial.base/server/door.cs (0): Unable to find object: ' ' attempting to call function 'Open'


my problem is that I have used echo() and I do find the object which is my door, I use echo() to make sure that I am finding my door, and the object is found yet It appears that it has actually not been found not sure what to do with this please give me a couple of hints

oh yeagh when I almost forgot how come if I save my .mis file and then review the door it shows up as TSStatic thats not what I wanted it to be.

here is the code

datablock StaticShapeData(ADoor)
{
category = "Doors";
shapeFile = "~/data/shapes/doors/door.dts";
};


function ADoor::OnAdd(%theDatablock, %whichDoor)
{
if(!%whichDoor.doorOpenFlag)
%whichDoor.doorOpenFlag = false;
if(!%whichDoor.rotationDirection)
%whichDoor.rotationDirection = 1;
if(!%whichDoor.maxOpenAngle)
%whichDoor.maxOpenAngle = $DOORS::MAX_ANGLE;

%whichDoor.currentRotation = 0;
%whichDoor.originalRotation = 0;
%whichDoor.partialTransform = "";
}

function serverCmdOperate(%client)
{
echo(%client);
echo(%player);
echo(%found);

%player = %client.player;
%eye = %player.getEyeVector();
%vec = vectorScale(%eye, $DOORS::PLAYER_REACH);
%start = %player.getEyeTransform();
%end = VectorAdd(%start,%vec);
%found = ContainerRayCast(%start, %end, -1, %player);

%found = Getword(%found, 0);

echo(%client);
echo(%player);
echo(%found);


if(%found)
%found.getdatablock.Operate(%found);

echo(%found);
}

function ADoor::Operate(%theDatablock, %whichDoor)
{
if (%whichDoor.doorOpenFlag == false)
{
%theDatablock.StartOpenSwing(%whichDoor);
}
}

function ADoor::StartOpenSwing(%theDatablock, %whichDoor)
{
%whichDoor.doorOpenFlag=true;
%whichDoor.currentRotation = 0;
%whichDoor.originalRotation = getword(%whichDoor.GetTransform(),6);
%z_unit_vector = getword(%whichDoor.GetTransform(),5);
if ( %z_unit_vector == 0 )
%z_unit_vector = "1";
%whichDoor.partialTransform = getwords(%whichDoor.GetTransform(),0,2) SPC $DOORS::XY_UNIT_VECTORS SPC %z_unit_vector;
%whichDoor.openSnd = %whichDoor.playAudio(0,doorStartOpenSwingSnd);
%theDatablock.IncrementSwing(%whichDoor);
}

function ADoor::IncrementSwing(%theDatablock, %whichDoor)
{
if ( %whichDoor.currentRotation < (%whichDoor.maxOpenAngle*$DOORS::RADIANS_PER_DEGREE))
{
%whichDoor.currentRotation += ( $DOORS::OPEN_INCREMENT * %whichDoor.rotationDirection);
%newrot = %whichDoor.originalRotation + %whichDoor.currentRotation;
%whichDoor.settransform(%whichDoor.partialTransform SPC %newrot);
%theDatablock.schedule($DOORS::OPEN_TIMER,"IncrementSwing", %whichDoor);
}
else
{
%theDatablock.schedule($DOORS::HOLD_TIMER,"StartCloseSwing",%whichDoor);
}
}

#1
02/14/2006 (11:35 am)
Camel - I created animated doors in Milkshape. The problem with creating animated doors in Milkshape is that the collision mesh doesn't aniamte properly, but if you only have 1 animation and 1 collision mesh it does.

This isn't the best solution, but it worked great for waht I wanted. If you do find you need multiple collision meshes or a part to stay stil and a part to move, you can create the whole thing in 1 file, and tehn export each piece seperately. WEhen you place it in the mission editor, place all the pieces and then copy over hte position and rotation of one to all the others... (F11 -> F3)
#2
05/29/2009 (8:03 pm)
Did you ever get your doors to work? If so how, as I am having the exact same problem!