Items Picking mit einem Ray Sensor

raysens
from bge import logic

####ray sensor with -z axis!!(mouse_look)

    
scene=logic.getCurrentScene()
cont=logic.getCurrentController()
    
own=cont.owner
    
click=cont.sensors["click"]
ray=cont.sensors["ray"]

if click.positive:
    if ray.positive:
        target=ray.hitObject
        if target.name=="Cylinder":
            target.endObject()
            own["Nahrung"]+=1
        if target.name=="Cylinder2":
            target.endObject()
            own["Nahrung"]+=1
        if target.name=="Cylinder3":
            target.endObject()
            own["Nahrung"]+=1
        if target.name=="Cylinder4":
            target.endObject()
            own["Nahrung"]+=1