Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using a modified version of the standard Unity First Person Controller. At the moment when I stand near walls, the camera clips through and lets me see through the wall. I know about camera occlusion and have implemented it in 3rd person games, but I have no clue how I'd accomplish this in a first person game, since the camera doesn't move from the player at all.

How do other people accomplish this?

share|improve this question
    
Maybe you could put a sphere collider on a parent game object of the camera? –  Rubber Mallet May 1 '12 at 21:33
    
Let me try that out –  Timothy Williams May 2 '12 at 0:41
1  
I haven't messed with the FP controller much in Unity but if your camera is passing through walls, doesn't that mean the player is passing through (or partly into) walls? Maybe the collidable component(s) of your controller need to be wider. –  chaosTechnician May 2 '12 at 14:55
    
Actually, I already have a capsule on the camera, it's what is attached to the camera as a default. However it's not a parent, does the parent part matter? I'll try adding a sphere collider to it, on top of the character controller collider. –  Timothy Williams May 2 '12 at 19:17
add comment

2 Answers

up vote 4 down vote accepted

It's probably an issue of your near clipping plane of your camera being further away than the radius on your character controller.

Either make the collision radius bigger or make the near clipping plane smaller.

If you look in the editor at the camera frustum you can easily tell if it's too far out compared to your collision radius. Here's an example:

Notice how the rear plane is clipping through the wall.

share|improve this answer
    
How can I go about making the near clipping plane smaller? –  Timothy Williams May 2 '12 at 19:22
2  
@TimothyWilliams it's a parameter in the inspector for the camera component. –  Tetrad May 2 '12 at 19:27
add comment

+1 to Rubber Mallet.

In "Unity 3.x Game Development Essentials" I saw the same example. Just put the camera on the top of sphere object(with collider). Also you could try to disable mesh renderer on it if you do not want to see the sphere.

share|improve this answer
    
I actually already have it that way, I use a charactercontroller, so it's not that that's causing the issues. I think it's what Tetrad said. –  Timothy Williams May 2 '12 at 19:23
    
Actually, I was thinking of the 3rd Person Controller. I'm pretty sure Tetrad's got the right idea. –  Rubber Mallet May 2 '12 at 23:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.