Author Topic: Checking if a position has brick or not?  (Read 489 times)

How would I check if the wanted position has a brick or not?

You have to use a raycast to do this. I personally have had issues with normal raycasts, so I like to use box raycasts.

Code: [Select]
function getBrickAtPos(%pos)
{
initContainerBoxSearch(%pos, "0.4 0.4 0.2", $typeMasks::FxBrickAlwaysObjectType);
%brick = containerSearchNext();
if(isObject(%brick))
return %brick;
return 0;
}
« Last Edit: February 23, 2012, 09:16:35 PM by Slicksilver »

Code: [Select]
function getBrickAtPos(%pos)
{
initContainerBoxSearch(%pos, "0.5 0.5 0.3", $typeMasks::FxBrickAlwaysObjectType);
%brick = containerSearchNext();
if(isObject(%brick))
return %brick;
return 0;
}
With that code, wouldn't it return the first brick it finds that's also at the sides?

I remember having issues with that. The search seems to do a bit of a wider area by a small amount.

I may be wrong though. I just remember that being an issue.

With that code, wouldn't it return the first brick it finds that's also at the sides?

I remember having issues with that. The search seems to do a bit of a wider area by a small amount.

I may be wrong though. I just remember that being an issue.
It should still get the brick inside it anyway. Oh well, I'll make the search box a teensy bit smaller.

It should still get the brick inside it anyway. Oh well, I'll make the search box a teensy bit smaller.
From what I remember, if you literally make it 0.0001 smaller on all axes it works.

From what I remember, if you literally make it 0.0001 smaller on all axes it works.
Oh well. There's no reason the above won't work anyway.