Game Development Community

How Does Masking Work For "pickLine()"?

by Leo Gura · in Torque Game Builder · 11/20/2006 (8:38 pm) · 4 replies

Well, the reference manual explains the "pickLine()" function as follows:

pickLine(%x1, %y1, %x2, %y2, [%groupMask = MASK_ALL], [%layerMask= MASK_ALL], [%showInvisible = false])

However, I still don't understand the 5th and 6th parameters of this funciton. Suppose I want to perform a pickLine for coordinates x1,y1 and x2,y2 for an object whose class is "player" and I want the invisible option enabled, how would I type that in exactly? Also, what does "MASK_ALL" mean? What should I type in if I want all object to be detected on all layers? Thanks.

#1
11/20/2006 (9:13 pm)
Look for the bits method in your TGB Reference Doc. You can use that to make a mask for groups or layers to pass into pickLine. I think you can just pass MASK_ALL to allow all layers/groups, or you could pass a list of the numbers from 0 to 30 to bits and use that ;)

So, you could put your player on a specific layer for itself, or just a group, and then make a mask using that number.

Hope that made some sense... ;)
#2
11/20/2006 (9:17 pm)
GroupMask and LayerMask are 32 bit bitmasks. A value of -1 for both will result in all layers and groups being checked.

...pickLine( %x1, %y1, %x2, %y2, -1, -1, true);
#3
11/20/2006 (9:21 pm)
Damn.. you actually beat me, Tom!! I must be slipping.

You will have to either use the Bit() function and 'bitwise or' to construct a mask or the actual uint represented by those bits. I don't think those mask arguments will take the space delimited string format for layers/groups. And MASK_ALL is not a global, but you can use -1 for all layers/groups.
#4
11/20/2006 (9:27 pm)
I was so shocked that you hadn't posted yet that I didn't explain it very well ;)