Trouble with mounted sprite collisions.
by Brandon Pollet · in Torque Game Builder · 05/26/2005 (12:29 am) · 1 replies
I have constructed an object from 5 fxStaticSprite2Ds into a cross shape. This object is created by specifying the middle piece then mounting the other four pieces to it. My problem is that the outer sprites do not collide correctly with the rest of the scene.
Think of a tetris-like game where the outer edges of the pieces pass through each other and a collision only occurs when the middles touch. I have included the code I am using to assign the collision information. In this code $player is the middle piece and pUp is mounted to it.
Think of a tetris-like game where the outer edges of the pieces pass through each other and a collision only occurs when the middles touch. I have included the code I am using to assign the collision information. In this code $player is the middle piece and pUp is mounted to it.
//Create initial piece
$player = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; } ;
$player.setPosition("0 -30");
$player.setSize( "5 5" );
$player.setImageMap(QCImageMap);
$player.setLinearVelocityY(5);
$player.setWorldLimit( clamp, "-32.5 -30 32.5 34" );
//set player's collision info:
$player.setGroup( 1 );
$player.setLayer( 1 );
$player.setCollisionActive( true, true );
$player.setCollisionMaterial( standardMaterial );
$player.setCollisionPolyPrimitive(4);
$player.setCollisionMasks( BIT(2), BIT(2) );
$player.setCollisionCallback( true );About the author
Brandon earned a Master's of Science in Computer Science from the University of Tulsa in 2005 before they asked him to leave. Since then he has worked in web development and mobile development all while honing his game design/programming skills.
Torque Owner Brandon Pollet
%pUp = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; } ; %pUp.setSize( "5 5"); %pUp.setPosition("0 -35"); %pUp.setImageMap(Q1ImageMap); %pUp.mount($player, "0 -2", 0); %pUp.setWorldLimit( clamp, "-32.5 -30 32.5 34" ); //set top part collision info: %pUp.setGroup( 1 ); %pUp.setLayer( 1 ); %pUp.setCollisionActive( true, true ); %pUp.setCollisionMaterial( standardMaterial ); %pUp.setCollisionPolyPrimitive(4); %pUp.setCollisionMasks( BIT(2), BIT(2) ); %pUp.setCollisionCallback( true );When a collision does occur I change the group and layer of the piece so that it becomes part of group/layer 2 and is collidable with the next piece. However the pieces just slide through each other unless the middle parts touch. I'm sure I am just missing something, any help would be appreciated.
Thanks