- Home /
Question by
Thejuster · Jun 18, 2013 at 09:07 AM ·
camerawallthird-person-camerabehind
Third person camera and Object
Hi all. i have a question for my rpg game.
If i use Third person camera, and the charater are example in wall.
The player can see behind wall.
how can I avoid that the camera does not pass through the wall?
Comment
Answer by TonyLi · Jun 18, 2013 at 03:47 PM
Use collision detection. You'll raycast back from the player. If the raycast hits something (like a wall), you need to move the camera in front of the point of collision.
Some examples already exist on the Unity wiki:
http://wiki.unity3d.com/index.php/Scripts/Controllers
http://wiki.unity3d.com/index.php/SmoothFollowWithCameraBumper
Here's 3DBuzz's comprehensive tutorial: