Game Development Community

Set animation to loop problem

by Mike Rowley · in Torque Game Engine · 11/22/2007 (8:33 am) · 5 replies

I have this one little thing left to do before I can shove my game out the door, and I can't figure out how to get it to work. Any help would be greatly appreciated.

I am using the blue guy as my avatar, so decided to put Kork at the end of the game waving at you.

I have this code:

datablock StaticShapeData(orcShape)
{
   category = "Misc";
   className = "MyTest";
   shapeFile = "~/data/shapes/orc_player/orc_player.dts";
   isPlaying = 1;
};

function MyTest::onAdd(%this, %obj)
{
	%obj.playthread(0, "celwave");

}

This works, but only plays once. I added a "looping = "true"; to it, but that canceled out the whole cs file.
I don't know if I can take the dsq into milkshape and change it to cyclic, so if I can, please tell me, or if there is another way....

#1
11/24/2007 (7:51 am)
After playing with this for 2 days, I've come to the conclusion that the dsq file can't be imported anywhere, so i can't change it to cyclic. (I even spent an hour downloading 3dsmax and tried using it.)
I decided to change the way I was doing this, as the only time I need the orc to wave is when the player is in front of it, so I changed my script. It now reads:
datablock StaticShapeData(orcShape)
{
   category = "Misc";
   className = "MyTest";
   shapeFile = "~/data/shapes/orc_player/orc_player.dts";
   isPlaying = 1;
};

function MyTest::onAdd(%this, %obj)
{
	%obj.playthread(0, "celwave");

}


//-----------------------------------------------------------------------------
datablock TriggerData(orcwaveTrigger)
{

   tickPeriodMS = 100;
};


//-----------------------------------------------------------------------------

function orcwaveTrigger::onEnterTrigger(%this,%trigger,%obj)
{

   Parent::onEnterTrigger(%this,%trigger,%obj);
   //orcShape.playthread(0, "celwave");
   %obj.playthread(0, "celwave");
}
......
If I use the orcShape.playthread, I get an error in the console that states it doesn't know what playThread is. If I use the %obj, it seems torque can't figure out which %obj I'm talking about.
Anyone know how I can get this to work?
#2
11/28/2007 (7:56 am)
I don't know if what we do is possible through script, but the way we do it is through the C++ code. In the advanceTime method of the player, we check if the animation has ended and replay it if we want it to loop. Assuming your animation is running in the action animation thread, the check would go somting like this:

if( mShapeInstance->getPos(mActionAnimation.thread) ==1.0 )
   if( WantLoopAnimation)
       replayCurrentAnimation();

Let me know if this helps.
#3
11/28/2007 (8:05 am)
@Mike: For the trigger method don't use the orcShape name but instead use the name that you gave the object when you placed it. If you didn't name it then you should do so.

If you don't want to use the trigger, or you still want it to loop anyways, try this:

function MyTest::onEndSequence(%datablock, %object, %slot)
     if (%slot == 0) {  // same as play thread
        %object.playThread(0, "celwave");
     }
end if
#4
11/28/2007 (3:49 pm)
Ok, I did the following: ( I only attempted the trigger becouse nothing else worked.)

datablock StaticShapeData(orcShape)
{
   category = "Misc";
   className = "MyTest";
   shapeFile = "~/data/shapes/orc_player/orc_player.dts";
   isPlaying = 1;
};

function MyTest(%this, %obj)
{
	%obj.playthread(0, "celwave");

}

//-----------------------------------------------------------------------------


function MyTest::onEndSequence(%datablock, %object, %slot)
     if (%slot == 0) {  // same as play thread
               %object.playThread(0, "celwave"); //Getting parse error here
                //} //This didn't stop the parse error.
      end if
      }
//--------------------------------------------------------------------

I don't get why I would be getting a parse error. The brackets are in the right places.
#5
11/29/2007 (12:18 am)
Remove the end if line and you should be fine.