please help near sensor tps

this is going to b a very annoying question becoz it’s outdated. please bear with me. After some searching i got a tps example that makes the player always move away from the camera, after some plating around, i got it to work in all directions, d problem is dat the camera passes through walls n even d floor. An idea came to me, that once d camera is near a wall or d floor, it should go closer to the character, but i can’t do this. Please help me or if u hav a tps already setup, please u can share it.

thanks alot, making a game requires real hard work and lots if time. Well i am learning phyton but it is not easy at all. Angel script is easier.