I'm making a game with target (orbit camera). I want to limit camera movements when in room. So that camera don't go through walls when moving around target and along the ground. What are common approaches? Any good links with tutorials? I use Unity3D, nevertheless I'm good with a general solution to the problem
A simple solution would be to cast a ray from the target to the desired camera position, and cap the camera position if it hits anything.
In Unity, it'd be something like this:
(Please note I've not tested the code!)
This might result in some sharp camera motions, but it's a reasonable starting point. I've certainly seen commercial games use the same system!
Usually you'll associate a collision volume with your camera, so that when it hits a wall (or floor, etc.), it stops moving. Some implementations wrap both the camera and the object it's following in the same collision volume, in order to avoid getting a wall between the camera and the object.
The physics acting on the camera collision volume should probably be different than the physics acting on the object it's following. The camera probably doesn't need to be affected by gravity, e.g.