Weird pickLine result or coding error?
by Teddy Setiawan Wijaya · in Torque Game Builder · 08/08/2008 (11:23 pm) · 6 replies
--- Some Background ----
I have three character on the scene (one player and two NPCs).
- The player(Natalie) is the one with the blue long sleeves.
- Yui is the character on the left
- Catherina is the character on the right
see screenshot at the bottom of the posting for better description.
Each character has its own collisionGroups and collisionLayers (defined using config datablock)
Player
Yui and Catherina have the same settings
I have defined the following function (checkLOS)
Now, here is what I get from executing the checkLOS function (cut and paste from console.log)
My questions are:
1. Why did pickLine from Player to Catherina yield empty result?
2. Why did pickLine result from Yui to Player include Yui (object id: 1964) ?
3. Why did pickLine result from Yui to Catherina only include Yui herself (object id: 1964) ?
screenshot

I have three character on the scene (one player and two NPCs).
- The player(Natalie) is the one with the blue long sleeves.
- Yui is the character on the left
- Catherina is the character on the right
see screenshot at the bottom of the posting for better description.
Each character has its own collisionGroups and collisionLayers (defined using config datablock)
Player
layer = 10; graphGroup = 30; collisionGroups = BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5); collisionLayers = BIT(10);
Yui and Catherina have the same settings
Layer = 10; collisionLayers = BIT(10); graphGroup = 1; collisionGroups = BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(6) | BIT(30);
I have defined the following function (checkLOS)
function checkLOS(%srcObj, %dstObj)
{
%result = false;
%srcPosition = %srcObj.getPosition();
%dstPosition = %dstObj.getPosition();
%srcCollisionGroups = %srcObj.collisionGroups;
%srcCollisionLayers = %srcObj.collisionLayers;
echo("checkLOS from ", %srcObj.charName, "(", %srcObj, ") to ", %dstObj.charName, "(", %dstObj, ")");
echo(%srcObj.charName, " collisionGroups is ", %srcObj.collisionGroups);
echo(%srcObj.charName, " collisionLayers is ", %srcObj.collisionLayers);
echo(%dstObj.charName, " graphGroup is ", %dstObj.graphGroup);
echo(%dstObj.charName, " layer is ", %dstObj.layer);
%pickLineRslt = $levelScene.pickLine(%srcPosition, %dstPosition, %srcCollisionGroups, %srcCollisionLayers, false);
echo("pickLine result is: ", %pickLineRslt);
if ((getWordCount(%pickLineRslt) == 1) && (%pickLineRslt == %dstObj) && (%dstObj.getVisible()))
%result = true;
return %result;
}Now, here is what I get from executing the checkLOS function (cut and paste from console.log)
Quote:
Natalie is created with obj pointer 1960
New steering created for object Natalie
Yui is created with obj pointer 1964
New steering created for object Yui
Augusto is created with obj pointer 1974
New steering created for object Augusto
Catherina is created with obj pointer 1982
New steering created for object Catherina
Adding AiGoalLookAround for agent Catherina
==>echo(checkLOS($player, $yui));
checkLOS from Natalie(1960) to Yui(1964)
Natalie collisionGroups is 62
Natalie collisionLayers is 1024
Yui graphGroup is 1
Yui layer is 10
pickLine result is: 1964
1
==>echo(checkLOS($player, $catherina));
checkLOS from Natalie(1960) to Catherina(1982)
Natalie collisionGroups is 62
Natalie collisionLayers is 1024
Catherina graphGroup is 1
Catherina layer is 10
pickLine result is:
0
==>echo(checkLOS($yui, $player));
checkLOS from Yui(1964) to Natalie(1960)
Yui collisionGroups is 1073741918
Yui collisionLayers is 1024
Natalie graphGroup is 30
Natalie layer is 10
pickLine result is: 1960 1964
0
==>echo(checkLOS($yui, $catherina));
checkLOS from Yui(1964) to Catherina(1982)
Yui collisionGroups is 1073741918
Yui collisionLayers is 1024
Catherina graphGroup is 1
Catherina layer is 10
pickLine result is: 1964
0
==>echo(checkLOS($catherina, $player));
checkLOS from Catherina(1982) to Natalie(1960)
Catherina collisionGroups is 1073741918
Catherina collisionLayers is 1024
Natalie graphGroup is 30
Natalie layer is 10
pickLine result is: 1960
1
==>echo(checkLOS($catherina, $yui));
checkLOS from Catherina(1982) to Yui(1964)
Catherina collisionGroups is 1073741918
Catherina collisionLayers is 1024
Yui graphGroup is 1
Yui layer is 10
pickLine result is: 1964
1
==>exitDemo();
My questions are:
1. Why did pickLine from Player to Catherina yield empty result?
2. Why did pickLine result from Yui to Player include Yui (object id: 1964) ?
3. Why did pickLine result from Yui to Catherina only include Yui herself (object id: 1964) ?
screenshot

#2
08/10/2008 (1:12 pm)
I just posted a bug report Here, on an issue that seems very similar to yours. Ok it looks like your characters have CollisionDetectionMode set to POLYGON, in which case I don't know if my issue and yours are the same. But you could try changing their CollisionDetectionMode to something else just to see how that affects your results.
#3
I'll try to have further experiment and post the result.
Cheers,
08/10/2008 (8:46 pm)
Thanks a lot James, I'll try to have further experiment and post the result.
Cheers,
#4
Here's the result:
- POLYGON => pickLine yield empty result if we cast the line to Catherina (object with the 'smallest' collision area)
- FULL => pickLine yield empty result if we cast the line to Catherina (object with the 'smallest' collision area)
- CIRCLE => it works! pickLine works as expected
Out of curiosity, after reading your bug report posting, I tried to change the collision poly list setting for Catherina with the collision poly list of the other character (the bigger one) and then test it again with POLYGON collisionDetectionMode, guess what.... IT WORKS!!
So it seems that like you wrote in your post, if the collision area is 'too small', the collision detection went haywire.
08/10/2008 (10:15 pm)
James, following your suggestion I tried experimenting with different setting for collisionDetectionMode.Here's the result:
- POLYGON => pickLine yield empty result if we cast the line to Catherina (object with the 'smallest' collision area)
- FULL => pickLine yield empty result if we cast the line to Catherina (object with the 'smallest' collision area)
- CIRCLE => it works! pickLine works as expected
Out of curiosity, after reading your bug report posting, I tried to change the collision poly list setting for Catherina with the collision poly list of the other character (the bigger one) and then test it again with POLYGON collisionDetectionMode, guess what.... IT WORKS!!
So it seems that like you wrote in your post, if the collision area is 'too small', the collision detection went haywire.
//Here's the collision polylist that doesn't work size = "8.000 16.000"; CollisionDetectionMode = "POLYGON"; CollisionPolyList = "-0.412 0.250 0.354 0.255 0.344 0.648 -0.403 0.653";
//Here's the collision polylist that works size = "8.000 16.000"; CollisionDetectionMode = "POLYGON"; CollisionPolyList = "0.639 -0.158 0.600 0.581 -0.613 0.581 -0.613 -0.158";
#5
11/01/2008 (10:26 pm)
Did your issue end up getting resolved? I did find a bug in the circle/polygon collision code and just posted a fix to the bug thread i posted previously.
#6
BTW, out of curiosity, if you don't mind to let me know what game are you working on? ;-)
11/02/2008 (1:57 am)
Hi James, no... there is no response for my issue... I don't want to delve into the source code so currently the only work around that I found is to make the collision poly list bigger.BTW, out of curiosity, if you don't mind to let me know what game are you working on? ;-)
Associate James Ford
Sickhead Games
Not sure.
@2. Why did pickLine result from Yui to Player include Yui (object id: 1964) ?
Because Yui is in graph group one, and Yui also has BIT(1) in the collision mask. If you do not want her to find herself, there is an optional parameter in pickLine for an "exempt" object that should not be returned.
@3. Why did pickLine result from Yui to Catherina only include Yui herself (object id: 1964) ?
Not sure, seems like it should be both of them, if, as you said, they both have the same data and are in graph group 1.
You could try have a global $losGroupMask and $losLayerMask, and have all los calls use that rather than a separate one as a field in each object ( and always have the srcObject as the exempt object ). That might make it clearer and easier to debug. You wouldn't get different results depending on who was the src and who was the dst.