Spawning a StaticShape with script code
by Thijs Sloesen · 09/13/2004 (9:17 am) · 3 comments
First we need a datablock:
Then we need a function to spawn the shape:
And last but not least a simple test function that we can call from the console to test our code and which spawns our shape at a random spawn point:
datablock StaticShapeData(MyShapeData) {
shapeFile = "~/data/shapes/blah/myshape.dts";
};Then we need a function to spawn the shape:
function createMyShape(%pos) {
%shape= new StaticShape(MyShape) { dataBlock = MyShapeData; };
MissionCleanup.add(%shape);
%shape.setTransform(%pos);
return %shape;
}And last but not least a simple test function that we can call from the console to test our code and which spawns our shape at a random spawn point:
function testMyShape() {
return createMyShape(PickSpawnPoint());
}About the author
#2
11/05/2004 (7:04 am)
Well, of course this example could form the basis for such code, but additional code would be needed for checking the ground angle etc., and to be honest, right now I am not deep enough in the Torque material with my head to write such code for you. But if you decide to give it a try, good luck! :)
#3
is there a way to override the tick function somehow in the scripts?
thanks!
10/25/2005 (5:29 am)
how do i update the position every frame within the script???is there a way to override the tick function somehow in the scripts?
thanks!
Matthew Crawford
For example, if I wanted to spawn a box. I would want to limit the play to a ground level of give or take 4 degrees from flat. If the ground angle was higher/lower the object placement would be denied. If it was within the limits of where the players curser was pointing, then allow the object to be placed, but matching the everage ground angle so it does'nt look like it's floating?