Game Development Community

Pickpoint question

by JD Scogin · in Torque Game Builder · 09/16/2007 (4:21 pm) · 3 replies

Again I have spent almost all day trying to figure this out. I have searched every where I can think of before I ask the question here. But alas, I can not find the answer.
I have an object on layer 30, one on layer 5 and one on layer 0.
My avatar is on level 5. What I want to do it walk in front of the one on layer 30, behind the one on layer 0 and bump into the one on level 5. Because of the way I am doing the graphic animation to make my avator walk, I need to use pickpoint to see if he will bump into anything before he moves.

So here is what the docs say about pickpoint:
Quote:
pickpoint(x / y, [groupMask], [layerMask], [showInvisible?], [excludeObjectId] )

"%values = %obj.pickPoint( "0 0", BIT(0)|BIT(1), BIT(0), true, %someObj )"
Ok here comes the questions. What is a group? How do I set it to All?
If I want to check to object on layer 5, how do I do that?

Here is the code I use and it does not work:

$space1 = SceneWindow2D.getScenegraph().pickPoint(%worldpos,0,BIT(0)|BIT(2));

Will 0 in the group positon set the groups to all?
I tried BIT(0) and set the object I wanted to check to group 1. Still did not work.
Anyone know what I am doing wrong?

#1
09/16/2007 (6:14 pm)
I'm pretty sure 0 will set it to all, but im not 100%. But, for the layer group, if you want to check layers, say 5 and 30, you put in "5 30" (again, im not 100% sure).

Give that a go n see what happens.

$space1 = SceneWindow2D.getScenegraph().pickPoint(%worldpos,0,"5 30");

Or, alternatively you can just pick the point regardless of which layer, then check for layer.

$space1 = SceneWindow2D.getScenegraph().pickPoint(%worldpos);

for (%i=0,%i<getWordCount($space1);%i++)
{
    %currObject = getWord($space1, %i);
    if (%currObject.layer = 5)
        do stuff...
}

The above might not be correct,, but you get the idea though.
#2
09/16/2007 (6:52 pm)
Yea, checking the pickPoint without checking the layer works fine.
But I need to check the layer.
I tried the syntax you suggested and it returned nothing.
Thanks for trying.
Jd
#3
09/17/2007 (6:41 am)
Well, I figured it out and it is very simple. Too simple.
The groups and layers have 31 bits.
You just have to select the bit for the group and layer.
So to select group 1, it would be BIT(1). To select layer 5, it would be BIT(5).
Here is the code that was wrong:
$space1 = SceneWindow2D.getScenegraph().pickPoint(%worldpos,BIT(0),BIT(0)|BIT(2));
I was trying to select the layer by or'ing the bits together. Bit 0 which is 1 and bit 2 which is 4 or'ed together would be 5. The layer I was looking for. All I really needed to do was select bit 5.
Here is the corrected code to select group 1, layer 5:
$space1 = SceneWindow2D.getScenegraph().pickPoint(%worldpos,BIT(1),BIT(5));
Very simple once I figured it out. Maybe everyone know this except me, now I do.
If you wanted to select two layers, just 'or' the bits together, as in the example "BIT(1)|BIT(5)".
All makes sense now.