Moving objects script questions.
by Paul Seyfarth · in Torque 3D Beginner · 04/03/2014 (7:54 am) · 5 replies
Right now working on a moving objects script, where you use a path and path markers to select the path you want the object to move. I have a basic working version right now. I currently use schedule and setTransform to move the object every two to five ms depending on what I set in schedule. So now I have a few questions.
1. Is there a better way to move the objects?
2. Where in the script do I add things for once the level and all objects are loaded?
3. Is there a time or tick function in torquescript
I have other questions but these were some main ones
1. Is there a better way to move the objects?
2. Where in the script do I add things for once the level and all objects are loaded?
3. Is there a time or tick function in torquescript
I have other questions but these were some main ones
About the author
#2
04/03/2014 (8:44 pm)
ScriptTickObject gives you ticks when the process list is being updated...
#3
Looks like I will want to make a game object something like pathWalker that inherits gameBase. Then add functionality to set that pathWalker to a path, and during processTick calculate the pathWalkers transform. Then to move the objects in the level that I want to move I mount the object to the pathWalker.
I am going to check out the AI stuff first to make sure there isn't something in there that will work just as well. Especially for the main reason I want to use it.
04/05/2014 (1:00 pm)
Hopefully I am figuring this out right, been doing lots more reading to understand the engine and how the different objects interact and work.Looks like I will want to make a game object something like pathWalker that inherits gameBase. Then add functionality to set that pathWalker to a path, and during processTick calculate the pathWalkers transform. Then to move the objects in the level that I want to move I mount the object to the pathWalker.
I am going to check out the AI stuff first to make sure there isn't something in there that will work just as well. Especially for the main reason I want to use it.
#4
A full script to make it move along the path in a loop is available below
http://www.codesampler.com/torque.htm
04/07/2014 (5:06 am)
If you just want an object to move you can use AI to move it using the path.A full script to make it move along the path in a loop is available below
http://www.codesampler.com/torque.htm
#5
04/07/2014 (1:54 pm)
Yeah I checked out AI and wrote a script that uses followPath, it actually uses some of the script I had written before for looping, getting the path, and the currentNode. I also wrote something so that if the player is in the enemys line of sight it will start running at the player.
Associate Chris Haigler
Jester Dance
2). Look at GameCore::onMissionLoaded() or GameCore::startGame(). There are several steps involved in loading a mission so you may want to step through the code to see how it all fits together.
3). No, there's no TScript function called when the engine 'ticks'. You can add one fairly easily, though. See processList.cpp, specifically where it generates the processTick signals. You should be able to call a console function each time a processTick signal is generated (every ~32ms).
With that said, it's usually better to avoid writing code that requires constant updates/polling in TScript. Do the 'heavy lifting' in C++ and let TorqueScript handle the higher level, lightweight stuff.