Placing a new object
by Justin Mosiman · in Torque Game Engine · 12/29/2006 (6:22 pm) · 0 replies
Hi,
I have created a new class called RTSBuilding, and it's parent is ShapeBase. I don't have anything unique about this class right now, just a class with only its constructor. I also created a RTSBuildingData class, and it's parent is ShapeBaseData. Again, there's nothing unique about this class. When I click the mouse button down, I want a object to be created of this class. So I thought this code would work:
The PlaceBuilding command gets called correctly and all that, but when I place it nothing happens. There aren't any errors or anything like that either. For some reason, if I have the parent of RTSBuilding be Player, and the parent of RTSBuildingData be PlayerData, the building is placed fine. Why is this?
Thanks
I have created a new class called RTSBuilding, and it's parent is ShapeBase. I don't have anything unique about this class right now, just a class with only its constructor. I also created a RTSBuildingData class, and it's parent is ShapeBaseData. Again, there's nothing unique about this class. When I click the mouse button down, I want a object to be created of this class. So I thought this code would work:
datablock RTSBuildingData(blockBuilding)
{
category = "Buildings";
shapeFile = "~/data/shapes/buildings/blockBuilding.dts";
};
function serverCmdPlaceBuilding(%conn, %transform, %data)
{
%building = new RTSBuilding()
{
datablock = %data;
scale = "1 1 1";
};
%building.setTransform( %transform );
MissionCleanup.add(%building);
}The PlaceBuilding command gets called correctly and all that, but when I place it nothing happens. There aren't any errors or anything like that either. For some reason, if I have the parent of RTSBuilding be Player, and the parent of RTSBuildingData be PlayerData, the building is placed fine. Why is this?
Thanks