SetCollisionActive doesn't work as it is supposed to do ?
by Alexander Bierbrauer · in Torque Game Builder · 05/20/2006 (10:10 am) · 0 replies
Hey there,
I've run again into a stupid problem. In my game... I have blocks falling down, when they hit the bottom they are getting converted to static blocks...
Here's my collision options code for the blocks:
the static block receives now the collision like this:
Does anyone know why it doesn't work ??
I've run again into a stupid problem. In my game... I have blocks falling down, when they hit the bottom they are getting converted to static blocks...
Here's my collision options code for the blocks:
function setCollisionOptionsToBlockField(%field)
{
%field.setCollisionActive(true, false);
%field.setCollisionPhysics(false, false);
%field.setCollisionResponse(CLAMP);
%field.setCollisionCallback(false);
%field.setCollisionMaxIterations(2);
%field.setLayer($GAME::BLOCK_FALLING_LAYER);
%field.setGraphGroup($GAME::BLOCK_FALLING_GROUP);
%field.setCollisionMasks(BIT($GAME::BLOCK_FIELD_GROUP)|BIT($GAME::PLAYER_GROUP)|BIT($GAME::BLOCK_FALLING_GROUP));
%field.setDebugOn(5);
}
function setCollisionOptionsToWallField(%field)
{
%field.setCollisionActive(true, true);
%field.setCollisionPhysics(false, false);
%field.setCollisionResponse(CLAMP);
%field.setCollisionCallback(true);
%field.setCollisionMaxIterations(2);
%field.setLayer($GAME::BLOCK_FIELD_LAYER);
%field.setGraphGroup($GAME::BLOCK_FIELD_GROUP);
%field.setCollisionMasks(BIT($GAME::BLOCK_FIELD_GROUP)|BIT($GAME::PLAYER_GROUP)|BIT($GAME::BLOCK_FALLING_GROUP));
%field.setDebugOn(5);
}As you can see, I'm turning off the receive-option for the blocks in setCollisionOptionsToBlockField. I'm doing this 'cause I don't want that onCollision gets called for this type of blocks.. the static fields will receive the collision of the falling block... ok...the static block receives now the collision like this:
function t2dSceneObject::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
switch(%srcObj.getGraphGroup())
{
case $GAME::PLAYER_GROUP:
checkPlayerCollision(%dstObj,%normal,%contactCount, %contacts);
case $GAME::BLOCK_FIELD_GROUP:
if(%dstObj.getGraphGroup() == $GAME::BLOCK_FALLING_GROUP)
{
setBlockFallingSpeed($GAME::CURRENT_BLOCK,0);
convertBlockToWall($GAME::CURRENT_BLOCK);
$GAME::CURRENT_BLOCK = 0;
spawnBlock();
}
case $GAME::BLOCK_FALLING_GROUP:
echo("autch! why?");
}
}the convertBlockToWall converts the falling block by creating new objects etc.. and deleting and removing the falling black by calling first removeFromScene and then safeDelete... well. yeah.. then it crashes... I think this happens cause TGB wanna send the falling black the collision too.. but why ?? I turned it off !Does anyone know why it doesn't work ??