Author Topic: Spawn bricks inside bricks  (Read 1122 times)

I've made a custom brick in Blender with the grid of a 1x1 flat, and one with 1x1FF, but with collisions and bounds larger than that (in height), and placing them manually on top of each other works perfectly. The collision is spot on, and the brick is placed, however, when I try to spawn it through a code, the brick is spawned, however, it does not have a collision box at all. Spawning it 1x1F OVER the bounding box will give it a collision box.

How can I spawn a brick through code "inside" of another brick, but still have its own separate collision box?

Code: [Select]
function brickLesserPlantData::onPlant(%data, %obj)
{
Parent::onPlant(%data, %obj);
%pos = %obj.getPosition();
%client = %obj.client;
%brick = new fxDTSBrick()
{
client = %client;
colorFxID = 0;
colorID = 1;
datablock = brick1x1Data; //I used my own 1x1FF brick here normally
isPlanted = 1;
position = getWord(%pos, 0) SPC getWord(%pos, 1) SPC getWord(%pos, 2) + 1;
// position = vectorAdd(%pos,"0 0 0.2");
rotation = "0 0 0 0";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
stackBL_ID = %blid;
};

if(!isObject(BrickGroup_ @ %blid))
{
new SimGroup(BrickGroup_ @ %blid)
{
bl_id = %blid;
name = %client.name;
};
MainBrickGroup.add(BrickGroup_ @ %blid);
}
%brick.setTrusted(1);
%brick.plant();
(BrickGroup_ @ %blid).add(%brick);
missionCleanup.add(%brick);
%client.brickgroup.add(%brick);
}

The majority of the code was taken from http://blockland.wikia.com/wiki/Spawning_bricks

If the engine has an overlap error and you force it to plant it will not create proper collision and possibly render in a horrible way

I'm pretty sure it's possible to get the bricks working in the same location.
If you blank out the brick grid collision in the blbs for one or both bricks, you should be able to place them in the same location.
(no u, d, b, or x. just -'s) See blb reference "Brick Grid" section.

I figured it out through some testing. Scheduling (delaying) the event to occur a few moments after fixed it, just as placing it a few moments after would.

If anyone needs it, this is how it looks

      schedule( t , objID or 0, functionName, arg0, ... , argN )

Code: [Select]
function brickLesserPlantData::onPlant(%data, %obj)
{
Parent::onPlant(%data, %obj);
%client = %obj.client;
%pos = %obj.getPosition();
%pos = getWord(%pos, 0) SPC getWord(%pos, 1) SPC getWord(%pos, 2) + 0.1;
schedule(500, %obj, createBrick, %client, brickLesserPlantFlowerData, %pos, 1, 0);
}
« Last Edit: August 03, 2017, 10:33:13 AM by Chriso »