Author Topic: Bricks Adjacent To a Brick  (Read 1135 times)

Is there a way to identify a brick that's touching another brick without using raycasting? Similar to the getDownBrick() function?

as far as I know, no, not unless it's above or below the brick.

In order to do that, you'd have to loop through all the bricks and check if their position relative to their width/length and to the target bricks positions match up.

like if the bricks position +(or -) their length(or width) is 1 +(or -) the target bricks x(or y) position.

In order to do that, you'd have to loop through all the bricks and check if their position relative to their width/length and to the target bricks positions match up.

like if the bricks position +(or -) their length(or width) is 1 +(or -) the target bricks x(or y) position.
So it'd be really tedious and inefficient to do it any other way than a raycast by the looks.

Use a box search (look in the Containers and Raycasts section of the reference PDF posted here) using the size of the brick. Relevant things assuming %brick is the brick you want to get the surrounding bricks of:
Code: [Select]
%brick.getWorldBoxCenter()
%brick.getDatablock().brickSizeX
%brick.getDatablock().brickSizeY
%brick.getDatablock().brickSizeZ
Note that the brickSize fields on the datablock are in BLB units, not Torque units; the conversion is that one cubic Torque unit is 2x2x5 BLB units (so halve X and Y, divide Z by 5 - then add 0.1 or so to expand the box outside the size of the brick's bounding box)

Have fun working it out! (You will benefit more from this than being given code)

Oh, right. I completely forgot about box searches. This is what happens when you stop scripting for almost a year and then try to pick it back up, lol. Thanks.

Ipquarx, please do not reply to coding help topics.