Game Development Community

Play animation

by Barry Gallagher · in Artist Corner · 06/10/2007 (8:20 am) · 17 replies

Im trying to play an animation as an ambient animation on what is basically a static shape.
So far it hasnt worked. The file comes up in the editor under shapes/misc and I am able to place it inworld but the animation has yet to play.
In the console it says that warp.cs has a "syntax error on line 14" .

Here is my script for the animation. The file is called "warp.cs" . The model is called "warp.dts" .

Quote:
datablock StaticShapeData(Warp)
{
category = "Misc";
shapeFile = "~/data/shapes/Laker/Sphere_Shader/Warp.dts";
};

function Warp::onAdd(%this,%obj)
{
%obj.playThread(0,"ambient");
}

function StaticShapeData::create(%block)
{
%obj = new StaticShape();
{
dataBlock = %block;
};
return(%obj);
}

#1
06/10/2007 (8:37 am)
What is line 14 of warp.cs?
#2
06/10/2007 (9:08 am)
The text within the quotes in my first comment is the actual warp.cs file itself copied and pasted.

I believe it to be the line
Quote:dataBlock = %block;

Im unsure what to change it to as I merely copied this script from someone else.
I was hoping some script demon would point me in the right direction.
#3
06/10/2007 (10:57 am)
I believe it could be that semicolon after the closing bracket (};) right after that line. Might want to remove it.
#4
06/10/2007 (1:39 pm)
Tried that.. still same error message!
#5
06/10/2007 (2:10 pm)
In this block of code:
%obj = new StaticShape();
{
dataBlock = %block;
};
There shouldn't be a semicolon after new StaticShape()

Hope thats what your looking for.
#6
06/10/2007 (2:16 pm)
Rubes just gave that suggestion Caleb. It didnt work. I wish that was all I needed to do.
#7
06/10/2007 (2:47 pm)
new StaticShape(); Should not be a semicolon.

}; Should be a semicolon.

In other words:
function StaticShapeData::create(%block)
{
   %obj = new StaticShape()
   {
      dataBlock = %block;
   };
   return(%obj);
}
#8
06/10/2007 (4:03 pm)
Here is the cs file as i have it now just to clarify.
Basically all I want is a cyclical animation on model.
I exported the animation as a morph animation. Is this wrong?
Its a simple sphere that I scaled by vertex rather then using the scale tool.

Quote:datablock StaticShapeData(Warp)
{
category = "Misc";
shapeFile = "~/data/shapes/Laker/Sphere_Shader/Warp.dts";
}
function Warp::onAdd(%this,%obj)
{
%obj.playThread(0,"ambient");
}
function StaticShapeData::create(%block)
{
%obj = new StaticShape()
{
dataBlock = %block;
}
return(%obj);
}
#9
06/10/2007 (7:17 pm)
Barry, try this:

datablock StaticShapeData(Warp)
{
   // The category variable determins where the item
   // shows up in the mission editor's creator tree.
   // Path is relative to where the script is executed from.

   category = "Misc";
   shapeFile = "~/data/shapes/Laker/Sphere_Shader/Warp.dts";
};

function Warp::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 ambient sequence is cyclic
   // this animation will run continously.

   %obj.playThread(0,"ambient");

}

function StaticShapeData::create(%data)
{
   // The mission editor invokes this method when it
   // wants to create an object of the given datablock
   // type.  You only need one of these methods for any
   // class/datablock type (in this case StaticShape).

   %obj = new StaticShape()
   {
      dataBlock = %data;
   };
   return(%obj);
}

function Warp::create(%data)
{
   // The mission editor invokes this method when it
   // wants to create an object of the given datablock
   // type.  You only need one of these methods for any
   // class/datablock type (in this case StaticShape).

   %obj = new StaticShape()
   {
      dataBlock = %data;
   };
   return(%obj);
}
#10
06/10/2007 (7:44 pm)
Whoops, Caleb was right. I was looking at the wrong line.
#11
06/11/2007 (3:24 am)
Now the script is loading without error, but there is still no animation playing.

Could somebody fill me in on how to export the vertex animation from max. Im exporting the animation inside the dts file, with a sequence helper called ambient and with morph animation ticked.

Its basically a sphere that scales. I animated it by moving the vertex inside editable mesh.


Its your standard ambient animation Im looking for.
#12
06/11/2007 (5:29 am)
This should play your animation, it is basic script for animation.

datablock StaticShapeData(Warp)
{
   category = "Misc";
   shapeFile = "~/data/shapes/Laker/Sphere_Shader/Warp.dts";
};

function Warp::onAdd(%this,%obj)
{
   %obj.playThread(0,"ambient");
}
#13
06/11/2007 (6:12 am)
Im getting to that stage where this is starting to get annoying. From all accounts it should be working by now.
The animation works in TGEA showtool no problem.

At first I forgot to tick the scale animation box when exporting which meant it didnt animate.
I have corrected that and now it animates fine in TGEA showtool.

At the moment I am scaling 2 spheres by having them skinned to bones and scaling the bones.
Both spheres are part of the same editable mesh.

I can add the model through the shapes menu rather then static shapes menu and am doing so.

The model is added to the world but the bones animation does not play.

I have 2 shaders applied to the model but that shouldnt effect it.
#14
06/11/2007 (6:15 am)
When i view the model in showtool the playing thread is called ambient so I have that right now.
#15
06/11/2007 (6:34 am)
Is scaling of bones supported?
#16
06/11/2007 (7:35 am)
That was one of the possibilities in my head, but it works in TGEA showtool as long as I tick the scale animation box on the sequence helper.

I even added some movement to the animation for troubleshooting purposes, but I got the same result it showed in TGEA showtool but the animation doesnt play automatically when I add the model in the world editor from the shapes menu. I think the problem is that I'm doing something wrong with the scripts in the server folder, but Im not sure .

Here are all the filenames and scripts that im using again.

I have my a model called warp.dts and its animation called warp.dsq (the sequence helpers called ambient) located in the folder "starter.racing/data/shapes/Laker/Sphere_Shader/".
Also In that folder I have warp.cs which has this script in it.
Quote:datablock TSShapeConstructor(WarpDts)
{
baseShape = "./warp.dts";
sequence0 = "./warp.dsq ambient";
};
In the server scripts folder I have another script named WarpInit.cs which has this script in it.
Quote:datablock StaticShapeData(Warp)
{
// The category variable determins where the item
// shows up in the mission editor's creator tree.
// Path is relative to where the script is executed from.

category = "Effects";
shapeFile = "~/data/shapes/Laker/Sphere_Shader/warp.dts";
};


function Warp::onAdd(%this,%obj)
{
%obj.playThread(0,"ambient");
}

Besides that I have added this to game.cs .
Quote: exec("./warpinit.cs");

Its a funny one because the WarpInit.cs file is loading because I can see my model in the Effects category under the shapes menu in the world editor. I just cant get the animation to play!
#17
06/11/2007 (11:19 am)
Answered my own question (again).
All I needed to do was add this to warpInit.cs.

Quote:exec("~/data/shapes/Laker/sphere_shader/Warp.cs");