Python code for parent to coliding obj/and set an obj to ray hitpos

parent to col obj:



import bge


def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    sens = cont.sensors['col']
    
    if sens.positive:
                
        own.setParent(sens.hitObject)

main()


set obj to ray hitpos:



import bge


def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    sens = cont.sensors['col']
    
    if sens.positive:
                
        own.position = sens.hitPosition
        

main()


Setup: col obj: set a collision (named:<< col >>) sensor on a sensor object (Physiks) and connect it with a python controller with the script

Setup: set to ray hitpos: 2 Objects: one with the ray-sensor and another with the python-controller with the script connect both

hope that will help someone , the scripts work on Blender 2.5x, but they are my first ones, report bugs, and happy blending

please stick your code betwen [noparse]

....

[/noparse]

Thx for the info