Resetting camera after camera collision (BGE) When my camera collides with my wall, after I move the camera back to where it isn't colliding with anything, the camera stays fixed very closely to the player. What can I add to the code below to fix that(or fix it with the blender logic bricks)?

from bge import logic

def collision(cont):

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

    if ray.positive:
        own.worldPosition = ray.hitPosition
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!