About animation and new objects.
by Houston Community College (#0014 · in Torque Game Engine · 03/20/2007 (9:31 am) · 1 replies
Hello all,
I have a trigger in the game my group is working on. My trigger works fine.
EXPLAIN: I have a fan (TSstatic) just sitting there; but, when I walk into the trigger it is replaced by the same object but this time it is the animated version of it. The net result is it looks as if the fan started spinning when I walked into the trigger. This is as planned BUT....
I notice when I call it this way:
// from within the onTriggerEnter method
if(! $fanCreated)
{
%poss = stillFan.position;
stillFan.delete();
%trigFan= new Item(Testfan01)
{
dataBlock=Testfan;
position = %poss;
scale = "0.2 0.2 0.2";
};
MissionCleanup.add(%trigFan);
%trigFan.playThread(0,"tester");
$fanCreated= true;
}
The fan spins and then slows down at the end of the loop then speeds up again. (Yes it is looping!)
This is odd. But I am supposed to be able to control the fan with stop Threead and such.
Now if I do this:
if(! $fanCreated)
{
%poss = stillFan.position;
stillFan.delete();
%trigFan=TestFan.create();
%trigFan.setTransform(%poss);
%trigFan.setScale("0.2 0.2 0.2");
$fanCreated= true;
}
The fan comes in as it is supposed to spinning smooth but backwards.
Forwards or backwards is not a problem but I'd like to know why.
Q1) Is this the best way to do this or should I try to have the animated fan there from the beginning and start and stop at will?
Q1 b. ) If so how do I do it?
Q2) Why does it spin smoothly with create() but funky when I use method 1 to add it to the scene? Am I missing something?
concerned,
JW
"Help me Obi-Wan Kenobi, you're my only hope" Star Wars
I have a trigger in the game my group is working on. My trigger works fine.
EXPLAIN: I have a fan (TSstatic) just sitting there; but, when I walk into the trigger it is replaced by the same object but this time it is the animated version of it. The net result is it looks as if the fan started spinning when I walked into the trigger. This is as planned BUT....
I notice when I call it this way:
// from within the onTriggerEnter method
if(! $fanCreated)
{
%poss = stillFan.position;
stillFan.delete();
%trigFan= new Item(Testfan01)
{
dataBlock=Testfan;
position = %poss;
scale = "0.2 0.2 0.2";
};
MissionCleanup.add(%trigFan);
%trigFan.playThread(0,"tester");
$fanCreated= true;
}
The fan spins and then slows down at the end of the loop then speeds up again. (Yes it is looping!)
This is odd. But I am supposed to be able to control the fan with stop Threead and such.
Now if I do this:
if(! $fanCreated)
{
%poss = stillFan.position;
stillFan.delete();
%trigFan=TestFan.create();
%trigFan.setTransform(%poss);
%trigFan.setScale("0.2 0.2 0.2");
$fanCreated= true;
}
The fan comes in as it is supposed to spinning smooth but backwards.
Forwards or backwards is not a problem but I'd like to know why.
Q1) Is this the best way to do this or should I try to have the animated fan there from the beginning and start and stop at will?
Q1 b. ) If so how do I do it?
Q2) Why does it spin smoothly with create() but funky when I use method 1 to add it to the scene? Am I missing something?
concerned,
JW
"Help me Obi-Wan Kenobi, you're my only hope" Star Wars
Torque Owner Houston Community College (#0014
I was using the Item Data class instead of a static shape. I did not realize the Item Data puts an automatic spin on the item. Also, I also found out how to add the fan into the game but then animate it when I want to.
I find it very hard to try to learn this Engine On my own. I now have a book that puts things in, at least, some sort of order.
animate a static object:
%obj.playThread(0, "sequenceName"); // %obj is the variable the object is assigned to
// 0 is a thread to play this animation in. Must not be in use.
// "sequenceName" being the name of the sequence given when the animation was created in 3ds Max or whatever.
hope to learn more and maybe contribute in the future.
JW