Author Topic: initContainerBoxSearch units  (Read 1944 times)


What exact value should I use for a 6x1x4 brick?
3 2 0.6
Correct me if I'm wrong but I'm pretty sure that 6x1x4 brick is 3 0.5 2.4 in Torque units.


That is rather odd. I tried using 3 0.5 2.4, but players that are even approximately 6 studs away are killed too from this code:
Code: [Select]
datablock fxDTSBrickData( brickSawBladeShapeData : brick1x6x5Data )
{
category = "Wario Ware";
subCategory = "Micro-Games";
uiName = "Sawblade";

brickSizeX = 1;
brickSizeY = 6;
brickSizeZ = 4;
brickFile = "./1x6x4.blb";
};

function brickSawBladeShapeData::onPlant( %this, %obj )
{
%obj.sawBlade = new staticShape()
{
position = %obj.position;
rotation = rotateVector( %obj.rotation, 3 );
datablock = sawBladeShapeData;
};

missionCleanup.add( %obj.sawBlade );

%obj.setRendering( false );
%obj.setColliding( false );
%obj.setRayCasting( false );
}

function brickSawBladeShapeData::onRemove( %this, %obj )
{
if ( isObject( %saw = %obj.sawBlade ) )
{
%saw.delete();
}
}

datablock staticShapeData( sawBladeShapeData )
{
shapeFile = "Add-Ons/System_WarioWare/shapes/sawblade.dts";

doColorShift = true;
colorShiftColor = "0.4 0.4 0.4 1";
};

function sawBladeShapeData::onAdd( %this, %obj )
{
%start = getWords( %obj.getTransform(), 0, 2 );
%rotation = vectorNormalize( axisToEuler( getWords( %obj.getTransform(), 3, 6 ) ) );
%interval = 25;
%speed = 0.075;
%maxDistance = 8;

%rota = getWord( %rotation, 0 );
%rotb = getWord( %rotation, 1 );

if ( mAbs( %rota ) > mAbs( %rotb ) )
{
if ( %roab > 0 )
{
%rotation = 3;
}
else
{
%rotation = 1;
}
}
else
{
if ( %rotb > 0 )
{
%rotation = 2;
}
else
{
%rotation = 0;
}
}

switch ( %rotation )
{
case 0: %offset = vectorScale( "1 0 0", %speed );
case 1: %offset = vectorScale( "0 1 0", %speed );
case 2: %offset = vectorScale( "-1 0 0", %speed );
case 3: %offset = vectorScale( "0 -1 0", %speed );
}

%this.sawMove( %obj, %start, %offset, 0, %maxDistance, 1, %interval );
}

function sawBladeShapeData::onCollision( %this, %obj, %col )
{
if ( %col.getClassName() $= "player" )
{
%col.setVelocity( vectorScale( vectorSub( %col.getPosition(), %obj.getPosition() ), 6 ) );
%col.hideNode( "headSkin" );
%col.kill();
}
}

function sawBladeShapeData::sawMove( %this, %obj, %start, %offset, %index, %limit, %direction, %interval )
{
cancel( %obj.sawMove );
// echo( "sawBladeShapeData::sawMove - " @ %index SPC %direction SPC %offset SPC vectorAdd( %start, vectorScale( %offset, %index ) ) );

if ( !isObject( %obj ) )
{
return;
}

if ( vectorDist( %start, %obj.getPosition() ) >= %limit && %direction == 1 )
{
%direction = -1;
}

if ( %index <= 0 && %direction == -1 )
{
%direction = 1;
}

%obj.setTransform( vectorAdd( %start, vectorScale( %offset, %index ) ) );
initContainerBoxSearch( %obj.getPosition(), "3 0.5 2.4", $TypeMasks::PlayerObjectType );

while ( isObject( %col = containerSearchNext() ) )
{
%this.onCollision( %obj, %col );
}

%obj.sawMove = %this.schedule( %interval, sawMove, %obj, %start, %offset, %index + %direction, %limit, %direction, %interval );
}

You need to make sure the 3 and 0.5 are around the right way based on it's rotation.

I made the sawblade model face (the sharp end) +Y axis if it helps. (Edit: New model.)
« Last Edit: January 07, 2012, 03:43:41 AM by Demian »

If the X axis is the long bit, then brickSizeX is wrong (it should be 6 and y should be 1). Fix that and then you just need to rotate "3 0.5 2.4" by the brick's angle like I said earlier.

Code: [Select]
switch(%brick.getAngleID()) {
case 0:
case 2:
%box = "3 0.5 2.4";
case 1:
case 3:
%box = "0.5 3 2.4";
}

That should work.

What kind of crazy system has Z as not being height?
Pretty much every game engine outside of torque. I hate it. Graphs should be XYZ in this format:

X, Y, and Z are in order from easiest to hardest based on continual motion, IMO.

X: If you walk forward it's incredibly easy.
Y: If you walk to the right it's kind've awkward.
Z: If you walk up you're laying on the ground wondering why the forget you did that.


Edit: Oops, bump.