Question about Chapter 3 Animation Test Program
by Sean Galland · in Torque Game Engine · 01/17/2005 (10:24 pm) · 4 replies
Hello,
When I run the Animation Test, it seems that all that happens is the heart drops to the ground, and sits there. First, it dropped below the surface of the ground, then I adjusted the scale to be 1.5 and now when the heart hits the ground, its visible, and just sits there and does absolutely nothing. Any assistance in solving this problem would be appreciative. I am sure its something small that I am simply overlooking :)
datablock ItemData(TestShape)
{
shapeFile = "~/data/shapes/items/heart.dts";
mass = 1;
friction = 1;
};
function InsertTestShape()
{
%shape = new Item() {
datablock = TestShape;
rotation = "0 0 1 0";
};
MissionCleanup.add(%shape);
%shape.setTransform("-90 -2 20 0 0 1 0");
echo("Inserting Shape " @ %shape);
return %shape;
}
function AnimShape(%shape, %dist, %angle, %scale)
{
%xfrm = %shape.getTransform();
%lx = getword(%xfrm,0);
%ly = getword(%xfrm,1);
%lz = getword(%xfrm,2);
%rx = getword(%xfrm,3);
%ry = getword(%xfrm,4);
%rz = getword(%xfrm,5);
%lx += %dist;
%angle += 1.0;
%rd = %angle;
if($grow)
{
if($scale < 5.0)
%scale += 0.3;
else
$grow = false;
}
else
{
if(%scale > 3.0)
%scale -= 0.3;
else
$grow = true;
}
%shape.setScale(%scale SPC %scale SPC %scale);
%shape.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rd);
schedule(200.0, AnimShape, %shape, %dist, %angle, %scale);
}
function DoAnimTest()
{
%as = InsertTestShape();
$grow = true;
AnimShape(%as, 0.2, -1, 1.5);
}
When I run the Animation Test, it seems that all that happens is the heart drops to the ground, and sits there. First, it dropped below the surface of the ground, then I adjusted the scale to be 1.5 and now when the heart hits the ground, its visible, and just sits there and does absolutely nothing. Any assistance in solving this problem would be appreciative. I am sure its something small that I am simply overlooking :)
datablock ItemData(TestShape)
{
shapeFile = "~/data/shapes/items/heart.dts";
mass = 1;
friction = 1;
};
function InsertTestShape()
{
%shape = new Item() {
datablock = TestShape;
rotation = "0 0 1 0";
};
MissionCleanup.add(%shape);
%shape.setTransform("-90 -2 20 0 0 1 0");
echo("Inserting Shape " @ %shape);
return %shape;
}
function AnimShape(%shape, %dist, %angle, %scale)
{
%xfrm = %shape.getTransform();
%lx = getword(%xfrm,0);
%ly = getword(%xfrm,1);
%lz = getword(%xfrm,2);
%rx = getword(%xfrm,3);
%ry = getword(%xfrm,4);
%rz = getword(%xfrm,5);
%lx += %dist;
%angle += 1.0;
%rd = %angle;
if($grow)
{
if($scale < 5.0)
%scale += 0.3;
else
$grow = false;
}
else
{
if(%scale > 3.0)
%scale -= 0.3;
else
$grow = true;
}
%shape.setScale(%scale SPC %scale SPC %scale);
%shape.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rd);
schedule(200.0, AnimShape, %shape, %dist, %angle, %scale);
}
function DoAnimTest()
{
%as = InsertTestShape();
$grow = true;
AnimShape(%as, 0.2, -1, 1.5);
}
#2
01/17/2005 (10:56 pm)
Oh, the book said something about running off to the right and you can chase it to see how the animation works... oh well lol. Thanks.
#3
Your problem is in this line:
It should be:
A comma between 200 and 0, its not 200.0. I made the same mistake heh.
02/04/2005 (12:19 pm)
@SeanYour problem is in this line:
schedule(200.0, AnimShape, %shape, %dist, %angle, %scale);
It should be:
schedule(200, 0, AnimShape, %shape, %dist, %angle, %scale);
A comma between 200 and 0, its not 200.0. I made the same mistake heh.
#4
However I can see two mistakes in the above code:
1) Halfway down:
Should be:
2) Second last line:
Should be:
I on the other hand cannot find my error. :( I am tempted to copy the above code just to see what happens...
Ian
Edit - Just tried it and it works fine, and it sinks through the ground, I don't think thats intended however. ;) Why won't mine work. ;(
Edit 2 - Ignore the -2 thing, yours is better, if you leave it at -2 the heart enters the game upsidedown. :)
02/27/2005 (2:10 pm)
Ok I am stuck on the same program, my heart has flatlined. :(However I can see two mistakes in the above code:
1) Halfway down:
if($grow)
{
if($scale < 5.0)Should be:
if($grow)
{
if([b]%scale[/b] < 5.0)2) Second last line:
AnimShape(%as, 0.2, -1, 1.5);
Should be:
AnimShape(%as, 0.2, -1, [b]-2[/b]);
I on the other hand cannot find my error. :( I am tempted to copy the above code just to see what happens...
Ian
Edit - Just tried it and it works fine, and it sinks through the ground, I don't think thats intended however. ;) Why won't mine work. ;(
Edit 2 - Ignore the -2 thing, yours is better, if you leave it at -2 the heart enters the game upsidedown. :)
Torque 3D Owner Ray Depew