Help with Tut-Chessboard

Hey all,
Sorry to bother everyone yet again but I was attempting to use the Chessboard tutorial to determine what objects the mouse is pointing to and I came across this;

      #Set the model itself to be collideable with the ray. If this model was
      #any more complex than a single polygon, you should set up a collision
      #sphere around it instead. But for single polygons this works fine.
      #Set a tag on the square's node so we can look up what square this is
      #later during the collision pass
      self.squares[i].find("**/polygon").node().setTag('square', str(i))

I want to see what hex the mouse is over and my hexes are more then a single polygon so I was wondering how to modify this code block to use a collision sphere instead.


The comment isn’t referring to intersection tests in general–you can do picking on hex board pieces just as easily as on single-polygon squares. You don’t need to use a CollisionSphere.

No doubt the comment is referring to the fact that this particular board is made up of squares that include a single node called “polygon” for the pickable part. See, the code is using the find() function to locate that single node.

But you don’t have to do it that way. This sample code is also using an old interface. There’s a newer NodePath.setCollideMask() that’s probably easier to use. You could replace all that complexity with something like:


And you could do the same thing with your hex tiles.