TurnShape.CS (PG 111)
by Karan · in Torque Game Engine · 08/30/2005 (7:25 pm) · 7 replies
I just got the book today and its really interesting. Anyways i was reading and going through book code and came across this example. I wrote the script down and ran the program and tested it out. For some reason the heart that is drawn out onto the screen keeps rotating. Like it rotates but then seems to keep doing its rotation.
From the console i called TurnShape ($tt, 10);
And after that it keeps rotating. I couldn't get it because there is no while loop, so why is it called it again and again.
Then anyways i thought id re-create the problem, and quit the map and tried to load it again. As i was loading it again, it was trying to locate this TestShape object i had created. The console was going crazy and kept saying these lines:
CH3/turnshape.cs (50): Unable to find object: '1384' attempting to call function 'getTransform'
CH3/turnshape.cs (60): Unable to find object: '1384' attempting to call function 'setTransform'
Did anyone else get this problem. Could someone please let me know why does it keep rotating, and why do i get these errors. I thought because i am using MissionCleanup.add(%shape) it should clean up this variable when the map exits.
Thank you for all your help you Torque gurus.
From the console i called TurnShape ($tt, 10);
And after that it keeps rotating. I couldn't get it because there is no while loop, so why is it called it again and again.
Then anyways i thought id re-create the problem, and quit the map and tried to load it again. As i was loading it again, it was trying to locate this TestShape object i had created. The console was going crazy and kept saying these lines:
CH3/turnshape.cs (50): Unable to find object: '1384' attempting to call function 'getTransform'
CH3/turnshape.cs (60): Unable to find object: '1384' attempting to call function 'setTransform'
Did anyone else get this problem. Could someone please let me know why does it keep rotating, and why do i get these errors. I thought because i am using MissionCleanup.add(%shape) it should clean up this variable when the map exits.
Thank you for all your help you Torque gurus.
About the author
#2
I had a look, but it looks as if the other thread was about a typo. It actually works and does what it does. It just has a problem when i exit the map, it still tries to find the object. Also in the map it keeps rotating it but there is no loop or anything.
Thanks
08/30/2005 (9:00 pm)
Hey Mark,I had a look, but it looks as if the other thread was about a typo. It actually works and does what it does. It just has a problem when i exit the map, it still tries to find the object. Also in the map it keeps rotating it but there is no loop or anything.
Thanks
#3
// an object of the given datablock type.
// we always create "static" re-spawnable rotating objects.
%obj = new Item() {
dataBlock = %data;
static = true;
rotate = true;
};
If your datablock for the object is a copy of a normal object. try setting rotate=false;
08/30/2005 (9:16 pm)
// The mission editor invokes this method when it wants to create// an object of the given datablock type.
// we always create "static" re-spawnable rotating objects.
%obj = new Item() {
dataBlock = %data;
static = true;
rotate = true;
};
If your datablock for the object is a copy of a normal object. try setting rotate=false;
#4
So commands/functions might be executed continuesly...
08/31/2005 (2:21 am)
You have to remember that some of the scripts are basically in a Game-loop...So commands/functions might be executed continuesly...
#5
But A, the book never mentions that the object will keep rotating, as there is a part about animation that is after that section, and secondly there was a Move function which was modified to make it a turn function through the book, and the moving didn't continue. For example the MoveShape ($tt, 50) moved the shape designated too by $tt 50 places up ahead, and that was it. It didn't keep going.
I am just trying to figure out why this keeps rotating. Did anyone else who has the book encounter this.
Plus i tried rotate=false, and it didn't work.
Thanks
08/31/2005 (3:25 pm)
Hmmm i understand that about the game loop, and i tried the rotate thing.But A, the book never mentions that the object will keep rotating, as there is a part about animation that is after that section, and secondly there was a Move function which was modified to make it a turn function through the book, and the moving didn't continue. For example the MoveShape ($tt, 50) moved the shape designated too by $tt 50 places up ahead, and that was it. It didn't keep going.
I am just trying to figure out why this keeps rotating. Did anyone else who has the book encounter this.
Plus i tried rotate=false, and it didn't work.
Thanks
#6
I understand the whole game loop thing. But then how come in these 2 game files i need to add this line
schedule(200,0,AnimSound, %snd, %dist);
I mean according, to what everyone talked about game loops then i shouldn't need to do anything using schedule. Could someone who did this or followed this example please explain it to me. I would greatly appreciate it.
Thank You
09/01/2005 (8:45 pm)
So i continued on and did the animshape.cs and animaudio.csI understand the whole game loop thing. But then how come in these 2 game files i need to add this line
schedule(200,0,AnimSound, %snd, %dist);
I mean according, to what everyone talked about game loops then i shouldn't need to do anything using schedule. Could someone who did this or followed this example please explain it to me. I would greatly appreciate it.
Thank You
#7
Add a Echo("Rotate..."); to the function, and check if the function is called multiple times (in the console ) somehow.
Or try debugging the script with TorqueDev or Torsion.
09/02/2005 (2:21 am)
Ignore that statement... I don't think you should have that by calling that functions...Add a Echo("Rotate..."); to the function, and check if the function is called multiple times (in the console ) somehow.
Or try debugging the script with TorqueDev or Torsion.
Torque Owner Mark Barner
mbarnatl