Game Development Community

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);
}

About the author

Recent Threads

  • Complete Newbie Questions

  • #1
    01/17/2005 (10:33 pm)
    Well, it's supposed to go along, beating and hopping (or just beating, I forget) until it hits a patch of quicksand, at which time it sinks. Since you adjusted the scale, it's probably too big to go through the quicksand anymore.
    #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
    02/04/2005 (12:19 pm)
    @Sean
    Your 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
    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. :)