SetCollisionPolyCustom problem
by James Steinmetz · in Torque Game Builder · 04/30/2005 (3:37 pm) · 6 replies
I used T2D_Vertex_Plotter.exe to get the values of these vertices. When I was done I had seven sides. So I coded this:
when I run the program i get this:
any suggestions?
$mario.setCollisionPolyCustom( 7, "[0.1944, -1] [0.9722, 0.2558] [0.9722, 1.0000] [-1, 0.9767] [-1.0000, 0.3488] [-0.5278, -0.0930] [-0.6111, -0.6977] [0.1944, -1] " );
when I run the program i get this:
fxSceneObject2D::setCollisionPolyCustom() - Invalid Custom Polygon Items '16'; expected 14
any suggestions?
About the author
#2
Maybe I'm confused or confusing....or don't understand setCollisionPolyCustom.
The 14 comes up in the console. So how would I change that?
04/30/2005 (4:09 pm)
I'm sorry.Maybe I'm confused or confusing....or don't understand setCollisionPolyCustom.
The 14 comes up in the console. So how would I change that?
#3
04/30/2005 (4:16 pm)
You've told PolyCustom to expect 14 vertices by passing in "7" as the first parameter. But your actually passing in 8, so its reading 16 vertex points. So change the 7 to 8 I think is what Matt is saying.
#4
I just started learning t2d script yesterday so,...
I get no errors in the console when I press 'd' but no image appears on screen either. This only started happening after I changed my 7 to an 8.
04/30/2005 (4:49 pm)
One Last Time...I just started learning t2d script yesterday so,...
I get no errors in the console when I press 'd' but no image appears on screen either. This only started happening after I changed my 7 to an 8.
// ************************************************************************
//
// Add your custom code here...
//
// ************************************************************************
// Create an image for Mario
datablock fxImageMapDatablock2D(marioImageMap)
{
mode = cell;
cellwidth = 128;
cellheight = 128;
textureName = "~/client/images/Mario.png";
};
datablock fxImageMapDatablock2D(playershipImageMap)
{
mode = full;
texturename = "~/client/images/playership.png";
};
datablock fxAnimationDatablock2D(test)
{
imageMap = marioImageMap;
animationFrames = "0 1";
animationTime = 2;
animationCycle = 1;
randomStart = 0;
};
new ActionMap(playerMap);
playerMap.bindCmd(keyboard, "d", "AnimateMario();", "");
playerMap.bindCmd(keyboard, "s", "MarioDown();", "MarioDownStop();");
playerMap.bindCmd(keyboard, "a", "MarioLeft();", "MarioLeftStop();");
playerMap.push();
CreatePlayer();
}
function CreatePlayer()
{
$player = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$player.setPosition ("-35 0");
$player.setSize ( "14 7");
$player.setImageMap( playershipImageMap );
$player.fireLinkPoint = $player.addLinkPoint( "0.45 0.2" );
$player.setWorldLimit( clamp, "-49 -37 40 37" );
// Set player's collision info:
$player.setGroup( 2 );
$player.setLayer( 2 );
$player.setCollisionActive( true, true );
$player.setCollisionMaterial( standardMaterial );
$player.setCollisionPolyCustom( 4, "-1 0 -0.1 -0.6 0.98 0.15 -0.1 0.7" );
$player.setCollisionMasks( BIT(1), BIT(1) );
$player.setCollisionCallback( true );
}
function AnimateMario()
{
$mario = new fxAnimatedSprite2D() { scenegraph = t2dSceneGraph; };
$mario.setPosition( "0 0");
$mario.setSize("10 10");
$mario.playAnimation(test);
$mario.setGroup( 1 );
$mario.setLayer( 1 );
$mario.setCollisionActive( true, true );
$mario.setCollisionMaterial( standardMaterial );
$mario.setCollisionPolyCustom( 8, "[0.1944, -1] [0.9722, 0.2558] [0.9722, 1.0000] [-1, 0.9767] [-1.0000, 0.3488] [-0.5278, -0.0930] [-0.6111, -0.6977] [0.1944, -1] " );
$mario.setCollisionMasks( BIT(2), BIT(2) );
echo("test");
}
function MarioDown()
{
$mario.setLinearVelocityY(10);
echo("Down");
}
function MarioDownStop()
{
$mario.setLinearVelocityY(0);
}
function MarioLeft()
{
$mario.setLinearvelocityX(-10);
echo("left");
}
function MarioLeftStop()
{
$mario.setLinearVelocityX(0);
}
function fxSceneObject2D::onCollision()
{
$mario.setLinearVelocityX(0);
echo("collision");
}
#5
04/30/2005 (6:02 pm)
Simple mistake :) One of those type that happens to us all
#6
05/01/2005 (1:20 am)
Can you actually use the square brackets and commas when defining collision polys? I must admit that I always go through and remove them.
Torque 3D Owner Matthew Langley
Torque