picking in bge?

Like the opengl picking where you click on something and it returns the id of the object, how do you do this in blender?

So if one wanted to make some kind of board game like… chess, how do they pick with a pointer (mouse) each square?

Many thanks

Using python and logic bricks, you can connect a “Mouse > Mouse over any” sensor connected to a controller set to Python.

By connecting a script like this:

cont = GameLogic.getCurrentController() # gets the controller the script is connected to
focus = cont.sensors['mouse over any'] # gets the sensor using the name of the sensor.

if focus.positive:
    object = focus.hitObject
    print object.name

Object is a KX_GameObject class, every object in the game engine is a instance of that class. For a list of functions that can be used on a KX_GameObject class check out tutorialsforblender.com, they also have some python tutorials.

thankyou very much

So it would be possible to get the cell of a grid then and check the cells properties. Would these properties be set with python or logic?