Resetting camera after camera collision (BGE)
Here's the answer;

Add an empty, slightly behind the player, and put the ray on that, set the ray distance to however long you wan it to be, and turn on true level triggering.

you will need to change the code a very small amount:

from bge import logic

def collision(cont):

own = cont.owner
scene = logic.getCurrentScene()
target = scene.objects['Camera.001']
ray = cont.sensors['Ray']

if ray.positive:
    target.worldPosition = ray.hitPosition


and viola! mow the camera is added to a position based on the empties ray! if the ray is obstructed, the camera moves to the closest position!