Posts Tagged follow
Unity terrain avoiding smart follow camera
Posted by whydoidoit in Project With Code on March 22, 2012

I’ve been needing a terrain avoiding follow camera, I couldn’t find one that was exactly right so I produced my own.
My script uses multiple different methods to keep the followed object in view:
* Desired location with the camera adjusted for terrain height
* Rise above structures
* Zoom in to be closer to the followed object
* Camera rotation (cut view) to a different angle
Each method can be weighted to give the effect that you prefer. Each method votes on how aggressive a movement it had to make in order to locate the camera in an unobstructed location, the winner gets to set the location of the camera.
You can download it here.
Here is it in operation – I’m moving the camera a bit to put it in difficult places, but mostly it’s under the control of the system.

Mike Talbot is Chief Visionary of 3radical. He started his career as a game programmer working for UbiSoft and Electronic Arts among others. Currently he is programming mobile applications in Javascript, HTML5 and ASP.NET.
email: 