Game Development Community

TGB 1.1 B2: setTileCollisionActive doesnt seem to work right

by Jason Cahill · in Torque Game Builder · 03/29/2006 (1:13 am) · 3 replies

Problem:
.setTileCollisionActive doesn't work consistently. When I create 7 tiles, only three result in having collision rectangles.

Scenario:
I'm creating a tile layer with a bunch of tiles. I want each and every tile to process collisions, so I create a tile, set its collision active, and scale the collision box to fit my imagery.

Here's the setup code:
function setLevelTile(%tileLayer, %x, %y)
{
   %tileLayer.setStaticTile(%x, %y, imdbTile);
   %tileLayer.setTileCollisionActive(%x, %y, true);
   %tileLayer.setTileCollisionScale(%x, %y, "0.5 0.5");
}
 
function createMap()
{
   $tmLevel = new t2dTileMap()
   {
      sceneGraph = t2dScene;
   };
 
   $tmLevel.setPosition("0 0");
   $tmLevel.setLayer(1);
   $tmLevel.setGraphGroup(2);
   $tmLevel.setCollisionMasks(BIT(5), BIT(1));
   $tmLevel.setCollisionCallback(true);
   
   $tl = $tmLevel.createTileLayer(5, 5, 4, 4);
   $tl.setSize((5 * 4) SPC (5 * 4));
   $tl.setCollisionActive(false, true);
   $tl.setCollisionCallback(true);
   $tl.setLayer(1);
   $tl.setGraphGroup(2);
   $tl.setPosition("0 0");
 
   setLevelTile($tl, 0, 0);
   setLevelTile($tl, 1, 1);
   setLevelTile($tl, 2, 1);
   setLevelTile($tl, 2, 2);
   setLevelTile($tl, 3, 0);
   setLevelTile($tl, 4, 0);
   setLevelTile($tl, 1, 2);
}

Here's the picture of the result:
tdn.garagegames.com/wiki/images/4/4e/SetTileCollisionBug.png
Notice that only 3 of the 7 tiles have collision rectangles. Am I doing something wrong?

#1
03/29/2006 (8:30 am)
Yes there is a typo in ConsoleMethod(t2dTileLayer, setTileCollisionActive, ..) in t2dTileMap.cc at about line 1975:

// (tileX, tileY, receive)
   else if ((elementCount == 1) && (argc > 3))
   {
      tileX = dAtoi(argv[2]);
      tileY = dAtoi(argv[2]); [b]// <-- This should be argv[3][/b]
      receive = dAtob(argv[4]);
   }

-Michael
#2
03/29/2006 (9:17 am)
Awesome! Thank you Michael!
#3
03/30/2006 (11:33 am)
Again, thanks Michael ... SDK Updated! (Rev#4070).

- Melv.