camera collision

how can i make camera collision in bge. i want the camera to move closer to the character whenever it comes close to an object. i have attached the blend file i am planning on using. there is no character yet, just a cube. but if you have any suggestions for it please say so.

thanks

Movement_1.blend (498 KB)

Here’s a tutorial, if you go to YouTube you can enable english captions.

Thats the code I’m using. it doesn’t work in my file, but it woks in his. I’m using the exact same setup.