Game Development Community

DataBlocks/Objects and creating them in the editor

by Demolishun · in Torque 3D Professional · 01/01/2013 (9:42 pm) · 1 replies

I am trying to figure out how to create an object from the in game editors. So far I can only reliably create a TSStatic. I tried adding the following code:
datablock ShapeBaseData(TeleporterData)
{
   shapeFile = "art/shapes/teleporter/teleporter.cached.dts";
   cameraMaxDist = "0.712091";
   category = "Teleporter";
};
And this in another script file:
function ShapeBaseData::Create(%data){
   echo("Creating a ShapeBase object.");
   %obj = new StaticShape(){
      dataBlock = %data;
   };
   return %data;
}

It will create the object when I double click it in the scripted objects section of the editor. However, it does not work. It stays at the origin point and does not render anything.

I cannot find any tutorial for how to add scripted objects for T3D. I see a bunch of old tutorials, but not for the latest. Another issue is I tried to name the class of the DataBlock to Telerporter, but the add object code never calls with that namespace. It only uses the ShapeBaseData namespace.

About the author

I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67


#1
01/02/2013 (5:20 am)
I fixed the above code:
// needed StaticShapeData, not ShapeBaseData
    datablock StaticShapeData(TeleporterData)  
    {  
       shapeFile = "art/shapes/teleporter/teleporter.cached.dts";  
       cameraMaxDist = "0.712091";  
       category = "Teleporter";  
    };
and:
function ShapeBaseData::Create(%data){  
       echo("Creating a ShapeBase object.");  
       %obj = new StaticShape(){  
          dataBlock = %data;  
       };  
       // I was returning %data, doh!
       return %obj;  
    }

It does now put the object in the level properly. But, I cannot move the object around the level properly. The editor seems to dislike moving the object around.
Edit:
Ahh, crap, snap to grid was on. Never mind on the editing issue.