- Home /
EDIT: I used to see through walls.
EDIT: The original post below is all well and good, but I learned what my problem was yesterday, and I thought I'd share my facepalm with you. Setting the clipping planes near nor far did anything, no setting change did anything to fix my problem. Couldn't figure it out for the life of me. So, why was I seeing through literally every single model and GameObject?
Because the player's camera was in front of the player! So it was reaching the model before the player reached the collider. D'oh!
One small issue comes up now, however. Placing the camera above my player is messing with forward movement. For some reason, I simply can't walk forward sometimes. Haven't spent too much time with it yet, but if anyone knows a solution to THAT, cool. Otherwise I'm gonna keep messing with it. God bless.
Further edit: moving the camera up or down seems to affect whether the player can move in a certain direction. I've been able to stop forward, left, right, or backward movement based on cam position.
END OF EDITS
Hello again. Solved an issue that I had asked about a couple of months ago, where the question was closed (wrongly) because the person who closed it assumed it was a duplicate question. That thread can be found here.
The gist of it was, no matter what I did my character could see through walls, cubes, 3d models, etc. as long as I stood close enough to them. The problem had nothing to do with the camera, culling masks, etc. as none of the traditional fixes did a lick of good to fix the issue. So I posted, got a snarky answer and a "topic closed" message back, and no assistance. Well, here we are, and the answer was so much easier than I though. What was it?...
Hey Conect11, when you had that window issue, was your character bouncing off the walls?
Please take a look at my thread here if you know how to prevent this.
hey, just looked at your post and unfortunately don't have an answer for it. That said, for the fun of it try expanding the collider around it like I did to about 1.1 and see if that prevents the issue.
I tried that but I ran into an issue... The collider around it doesn't actually do much! :O
For some reason, my empty game object's collider isn't like regular colliders that will prevent it from going into walls. I probably need a mesh collider. :/
just fyi, I had to play with the collider size. At first I was having the same issue until I found the parameters I needed.
Answer by Conect11 · Nov 11, 2013 at 03:11 PM
Simply increase the size of the box collider around the wall / cube by a tiny little bit. I posted this topic in the event that someone else has the same issue. God bless.
Answer by AlucardJay · Nov 11, 2013 at 07:10 PM
The problem you're having is something even AAA titles have problems with. It is often called occlusion culling, and happens because the near clip plane of the camera is behind a renderer.
There are many tricks but I really don't think your solution is good in the long term. For example when you start putting particles/decals/quads(bulletholes) around your scene and are using raycast, you will have to start factoring in the offset of the collider to the rendered surface. And everytime you introduce something to a scene, you have to rescale the collider.
As the issue is with the camera, work with that. I have read things like putting a collider on the camera; or have raycasts that detect when something is very close to the near-clip plane of the camera and tells it to compensate by moving, or tells the controller to not move in that direction. The technique also depends on the type of camera, I assume you mean 1st person, but there is also 3rd person, top down, etc.
In summary, I think you are going down the wrong path that leads to lots of unnecessary work. Work on stopping the camera from seeing through things. Who knows, maybe you just need to decrease the near clipping plane in the inspector.
http://docs.unity3d.com/Documentation/Components/class-Camera.html
http://docs.unity3d.com/Documentation/ScriptReference/Camera-nearClipPlane.html
http://answers.unity3d.com/questions/129030/why-is-near-clip-plane-necessary.html
.
actually alucardj, that's brilliant. I hadn't even thought to put a collider on my camera! Definitely seems like that would save a metric butt - ton of work.
Had tried the clipping plane thing, which seemed like the most obvious solution, but alas, no. The collider on the camera looks promising, though. Thank you!
EDIT: Hmm, perhaps need to play around with it, but adding a collider to the camera simply slowed it down. Tremendously :(
If you are not using a rigidbody component, then this should be fine. Further down the line, you may also want to look at Layer-Based Collision Detection, so it only collides with static scene objects (or calculating headshots would be another head collider on a separate layer).
adding a collider to the camera simply slowed it down : sorry, but you simply have not provided enough information for anyone to help you.
is it a first person character controller (and is it the standard Unity one) ?
is it a rigidbody controller?
what is the association between the camera and the controller (scripted camera movement, camera as child of controller, camera following target object)?
What did you do? Did you add a sphere collider to an empty GameObject, and made that object a child of the camera, and it slowed your camera down? $$anonymous$$aybe try a box collider aligned to the near clipping plane. It really depends on your setup.
hey, sorry about that. Yes, it's the standard Unity first person controller. There is no rigidbody anywhere on my character. (though there is one on each weapon, the path being Character - Camera - Weapon Switching - Arm - Weapon 1 - Weapon 2, though I don't think that's relevant info, I could be wrong) As far as the association between camera and controller goes, the character controller is set on the "Player," and the camera is a child of the player. What I did was simply add a box collider directly to the camera.
Another method is increasing the radius of the character controller.
Your answer
![](https://koobas.hobune.stream/wayback/20220613121637im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GameObject disappear as I move/rotate the camera 1 Answer
Where To Learn Occlusion Culling Scripts 1 Answer
Which plane is which with CalculateFrustumPlanes 3 Answers
GameObject Instantiated Off Camera 0 Answers
Is it possible to render a solid color where the Camera clips to the Near Clipping Plane? 1 Answer