Game Development Community

animating an itemData object

by Brian Carlson · in Torque Game Engine · 06/07/2009 (8:15 pm) · 3 replies

Hey everyone. I'm trying to animate an item in the starter.fps. I have a little gold coin that I would like to move up and down. I've searched the forums quite a bit and found info on animating static shapes, but not for itemData. I found this www.garagegames.com/community/forums/viewthread/34923 so I would like to stick with the itemData type. I based it off the health patch. Here's my datablock:
datablock ItemData(goldCoin)
{
   category = "Health";

   shapeFile = "~/data/shapes/items/goldCoin.dts";
   mass = 1;
   friction = 1;
   elasticity = 0.3;
   sequence0 = "~/data/shapes/items/goldCoin_root.dsq root";

   repairAmount = 1;
   maxInventory = 100;
};

I also tried this:
function goldCoin::onAdd(%this,%obj)  
 {  
    // %obj is the object being added to the world  
    // with %this datablock.  Start up a thread on the  
    // new object.  Since the wave sequence is cyclic  
    // this animation will run continously.  
    %obj.playThread(0,"root");  
 }

but I think that only works with static shapes. I have tried calling the object directly in the console by naming the directly first:
first_gold.playThread(0,"root");
and enclosing that in an echo(); returned 0. I'm not getting any console errors related to this. I am using a .dsq file for the animation, and I've animated the player and bot with my own animations using my own, so I'm confident I'm doing that correctly. Currently the .dts just sits there. This individual thing isn't all that important, but I could see picking up animating items in general quite useful, but I couldn't find anything on that searching. Any help would be greatly appreciated! Thanks!

#1
06/09/2009 (5:21 am)
Have you tested the animation in ShowTool?

I think you need to load the sequence in its own datablock like this;

datablock TSShapeConstructor(PlayerDts)
{
   baseShape = "./player.dts";
   sequence0 = "./player_root.dsq root";
};

or in your case:

datablock TSShapeConstructor(goldCoin)
{
   baseShape = "./goldCoin.dts";
   sequence0 = "./goldCoin_root.dsq root";
};

Look at C:\~example\starter.fps\data\shapes\player\player.cs
#2
06/09/2009 (9:29 am)
got it! Thanks! It turns out I wasn't loading that cs file. I also had to add '%obj.playThread(0,"root");' to the datablock's onAdd function.
#3
06/09/2009 (9:50 am)
I'm thinking of writing a little resource on this. I know it's simple, and I found How can I play animations in .dts files? at the bottom of the page there just now, but there are several little steps involved that are a pain for someone just starting out. Thanks for the help!

Edit: resource