Game Development Community

playcel broken in Beta 5

by Judy L Tyrer · in Torque 3D Professional · 09/06/2009 (4:59 pm) · 3 replies

In Beta 4 the following code:
commandToServer('playCel', "myanimation");

caused the animation "myanimation" to play.

I moved the same collada file and all the animation code from Beta4 to Beta5. The TSShapeConstructor code is as follows:

function AmyDts::onLoad(%this)
{
   %this.addSequence("ambient", "root", "0", "30");
   %this.addSequence("ambient", "run", "40", "120");
   %this.addSequence("ambient", "myanimation", "130", "150");
   %this.setSequenceCyclic("Run", "1");
}

singleton TSShapeConstructor(AmyDts)
{
   canSaveDynamicFields = "1";
   baseShape = "art/shapes/players/Amy/Amy.DAE";
   upAxis = "DEFAULT";
   unit = "-1";
};

In Beta5 even though the commandToServer code is being called, the animation is not being played.


#1
09/06/2009 (6:03 pm)
Updating my own thread...

The animation works correctly with AIPlayer using
%this.animate("myanimation");

In the code for the player character, the animation is set correctly in player::setActionThread(). It is in the animation list and it set as mActionAnimation.action. I'm still trying to figure out why it is not playing. I'm in third person camera since I didn't see the bobbing I expected in first person camera.
#2
09/06/2009 (7:38 pm)
Okay, I found it....

It is prepending "cel" to the animation and thus "celmyanimation" was not being found. The action that was set was "ambient". It was listed as 19 which in the animationList was "myanimation" while "ambient" is number 18, but in stepping through the code it seems that the list automatically increments the list by 1 so that datablock.actionlist[0] is referenced as datablock.actionlist[1]. I've never seen this. In the debugger it shows a little 1 inside the icon for array. No wonder I was confused.

So I'm not sure what got changed from Beta4 to Beta5, but removing 'cel' @ from the playCelAnimation function fixed the problem.

It's also possible that I had made that change in Beta4 but missed making it in Beta5.
#3
09/07/2009 (2:11 am)
You may not want to change that function. It may be better to add your own functions:

I gave example functions below...I am sure you'll understand.

> Beta 5-Demos-PhysX-game-scripts-server-player.cs
function Player::PlayJudyanimation(%this,%anim)
{
if (%this.getState() !$= "Dead")
%this.setActionThread(%anim);
}

> Beta 5-Demos-PhysX-game-scripts-server-commands.cs
function serverCmdPlayJudy(%client,%anim)
{
if (isObject(%client.player))
%client.player.PlayJudyanimation(%anim);
}

> Beta 5-Demos-PhysX-game-scripts-client-default.bind.cs
moveMap.bindCmd(keyboard, "ctrl w", "commandToServer('playJudy',"wave");", "");
moveMap.bindCmd(keyboard, "ctrl s", "commandToServer('playJudy',"salute");", "");

-----------------------------------------------
..odd example but workable.