Correct syntax to generate Paths
by Andy Hawkins · in Torque Game Engine · 09/29/2007 (6:55 am) · 5 replies
I want to create paths and markers on the fly so I can use Torque's existing Path functionality. It's so I can continually update the path of ship do dodge things, but smoothly fly around.
I'm stuck on this bit. Below the first bit (my pseudocode) is the code that appears in a .mis file. But I couldn't code it like that. I would have to do something like...
...but I can't find any code about this on the GG pages. My searches end up in pathed cameras and AI paths.
Has anyone got a code snippet on how to do this please?
I'm stuck on this bit. Below the first bit (my pseudocode) is the code that appears in a .mis file. But I couldn't code it like that. I would have to do something like...
%path = new Path(something);
%path.insertMarker(markerClass);...but I can't find any code about this on the GG pages. My searches end up in pathed cameras and AI paths.
Has anyone got a code snippet on how to do this please?
new Path(Human1Path) {
canSaveDynamicFields = "1";
isLooping = "1";
new Marker(Marker1) {
canSaveDynamicFields = "1";
internalName = "wait5";
position = "792.084 832.16 -28.8";
rotation = "1 0 0 0";
scale = "1 1 1";
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
new Marker(Marker2) {
canSaveDynamicFields = "1";
position = "699.117 795.757 -29.0381";
rotation = "1 0 0 0";
scale = "1 1 1";
seqNum = "2";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
#2
09/29/2007 (8:20 am)
You da man! Thanks very much :) It's almost exactly the same code as in the .mis file. TorqueScipt rocks!
#3
09/29/2007 (8:28 am)
Aye, the mission file is Torque Script ;)
#4
Just use:
[coode]
%path = new Path() { ... };
%marker = new Marker() { ... };
%path.addObject(%marker)
[/code]
09/29/2007 (8:13 pm)
If you want to add the markers after creating the path (rather than part of the constructor).Just use:
[coode]
%path = new Path() { ... };
%marker = new Marker() { ... };
%path.addObject(%marker)
[/code]
#5
09/30/2007 (12:10 am)
@Brian - that was my next question. Thank you.
Torque Owner Tim Heldna
function addPath() { // Create our path object %path = new Path(Human1Path) { canSaveDynamicFields = "1"; isLooping = "1"; // Add some markers to our newly created path object new Marker(Marker1) { canSaveDynamicFields = "1"; internalName = "wait5"; position = "792.084 832.16 -28.8"; rotation = "1 0 0 0"; scale = "1 1 1"; seqNum = "1"; type = "Normal"; msToNext = "1000"; smoothingType = "Spline"; }; new Marker(Marker2) { canSaveDynamicFields = "1"; position = "699.117 795.757 -29.0381"; rotation = "1 0 0 0"; scale = "1 1 1"; seqNum = "2"; type = "Normal"; msToNext = "1000"; smoothingType = "Spline"; }; }; // Add the path to the mission group MissionCleanup.add(%path); // Create a new SimGroup that will hold our path new SimGroup (Paths) {}; // Add the path we created above to the SimGroup Paths.add(%path); // Use Marker1.getTransform() & Marker1.setTransform() // to obtain and set the position of said marker respectively. // Type Marker1.dump into console to view all available methods // Type Paths.dump into console to view all available methods }