Torquescript: Gameloop-like rotation, movement?
by Simon Sirius · in Torque 3D Beginner · 02/19/2013 (5:59 pm) · 4 replies
Hi, i just started to have a look at torquescript and I read that everything with TorqueScript is event-based. Because of that it is unclear to me, how to implement gameloop - like features.
Specific problems:
1. I want to rotate an object continuously via script. How would I do that?
2. I want to move an object continously in a certain direction?
(I am aware on how to use setTransform(), I just don't know on how get it called in a reapeated fashion, aka usually from within the gameloop.)
Specific problems:
1. I want to rotate an object continuously via script. How would I do that?
2. I want to move an object continously in a certain direction?
(I am aware on how to use setTransform(), I just don't know on how get it called in a reapeated fashion, aka usually from within the gameloop.)
#2
you can schedule functions to run after an amount of time.
you can even schedule functions on objects to run
02/20/2013 (5:12 am)
@Simon, as Ahsan points out, take a look at schedule..you can schedule functions to run after an amount of time.
you can even schedule functions on objects to run
#3
02/20/2013 (7:55 am)
alright thanks a lot. i am still having some issues wrapping my head around the programming concept.
#4
TorqueScript's intended use is to allow the developer to react to events generated by the engine. In most cases the scripting system should be doing nothing until an event (an object is added/removed, an AIPlayer has reached a destination, etc.) has occurred.
Look at the Item class (item.h/item.cpp) in the engine for an example of an object that can be set to rotate (around the z-axis) constantly.
02/20/2013 (10:31 am)
Ideally you want to handle things like movement and rotation (and anything that would be put into a typical game loop) from within the engine/in C++.TorqueScript's intended use is to allow the developer to react to events generated by the engine. In most cases the scripting system should be doing nothing until an event (an object is added/removed, an AIPlayer has reached a destination, etc.) has occurred.
Look at the Item class (item.h/item.cpp) in the engine for an example of an object that can be set to rotate (around the z-axis) constantly.
Ahsan Muzaheed
Default Studio Name
{
//do your work
cancel($schDoLoop);
$schDoLoop=schedule(500,0,"doLoop","");
}
$schDoLoop=schedule(500,0,"doLoop","");