Skip to content

Instantly share code, notes, and snippets.

@qoh
Created February 25, 2013 11:49
Show Gist options
  • Save qoh/5029318 to your computer and use it in GitHub Desktop.
Save qoh/5029318 to your computer and use it in GitHub Desktop.
%start = %this.getEyePoint();
%beam = vectorScale( %this.getEyeVector(), 2.5 );
%stop = vectorAdd( %start, %beam );
%ray = containerRayCast(
%start, %stop,
$TypeMasks::FxBrickObjectType, %this
);
if ( isObject( firstWord( %ray ) ) )
{
%pos = getWords( %ray, 1, 3 );
}
else
{
%pos = %stop;
}
initContainerRadiusSearch(
%pos, 0.75,
$TypeMasks::FxBrickObjectType
);
while ( isObject( %col = containerSearchNext() ) )
{
// your validation goes here
// for example
//
// if ( %col.isSlippery )
// {
// continue;
// }
%dist = vectorDist( %pos, %col.getWorldBoxCenter() );
if ( !strLen( %best ) || %dist < %best )
{
%best = %dist;
%targ = %col;
}
}
if ( !isObject( %targ ) )
{
// nothing hit
return;
}
// do things with %targ
// %targ is the brick to do things with k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment