Game Development Community

A little help starting out...

by Ron Barbosa · in Torque Game Engine · 06/28/2004 (9:18 pm) · 4 replies

Hey all...I've recently purchased a license for the Torque Game Engine...and I wanted to try a few things out using the included demo and Torque Script.

I've been reading Kenneth Finney's book, and I wrote a script that will basically take an object ID and move that object up along its Z-axis indefinitely.

I'm using this basic format:

(CONTENTS of test_translate.cs)

function test_translate(%entity_id)
{
      %transform = %entity_id.getTransform();
      %xpos = getWord(%transform, 0);
      %ypos = getWord(%transform, 1);
      %zpos = getWord(%transform, 2);
      %xrot = getWord(%transform, 3);
      %yrot = getWord(%transform, 4);
      %zrot = getWord(%transform, 5);
      %last = getWord(%transform, 6);
      %zpos+= 0.05;
      %entity.setTransform(%xpos SPC %ypos SPC %zpos SPC %xrot SPC %yrot SPC %zrot SPC %last);
}

Now...if I run this script several times...I will see that slowly, but surely the object is rising along its z-axis. But what I would like to do is run this script indefinitely...and be able to watch the building slowly rise up from the ground.

I've tried putting the entire function body in a while(1) loop, but since this loop never returns...my function call never returns...and the console remains on the screen.

I'm sure there are a million better ways to do this...but I'd just like to start off really simply.

If anyone with more Torque experience can suggest to me what a good solution is...I would appreciate it.

I left my copy of Finney's book at home and I'm away all week, but I do have the demo that I'm playing with until I return.

Again...I'm trying to stay simple until I can get a good handle on how custom scripts fit into the larger scheme.

Thanks in advance...
--RB

#1
06/28/2004 (9:24 pm)
function test_translate(%entity_id)
{
   %transform = %entity_id.getTransform();
   %xpos = getWord(%transform, 0);
   %ypos = getWord(%transform, 1);
   %zpos = getWord(%transform, 2);
   %xrot = getWord(%transform, 3);
   %yrot = getWord(%transform, 4);
   %zrot = getWord(%transform, 5);
   %last = getWord(%transform, 6);
   %zpos+= 0.05;
   %entity.setTransform(%xpos SPC %ypos SPC %zpos SPC %xrot SPC %yrot SPC %zrot SPC %last);

   if(isObject(%entity_id))
      schedule(250, 0, "test_translate", %entity_id); 
}
The schedule will run the function every 1/4 secs and run indefinantly as long as the %entity_id exists.
#2
06/28/2004 (9:31 pm)
function test_translate(%entity_id)
{
   vectorAdd(%entity_id.getPosition(), "0 0 0.05");

   if(isObject(%entity_id))
       schedule(100, 0, "test_translate", %entity_id);
}
#3
06/29/2004 (8:43 am)
Beautiful, man...thanks alot. I was not aware of a scheduler. I'm sure this will be covered in Finney's book...I just haven't gotten to that chapter yet. ;)

Thanks again, man...
--RB
#4
07/03/2004 (4:10 pm)
Where can I find more info on getTransform & getPosition?

They aren't the reference section of the book and I must have overlooked it somewhere on this site.