Camera rotates through walls

My camera will not collide with objects, I put a break point in on ThirdPerson.move and I can see the spherecast going but it doesnt move past the if statement on line 448. I have checked that these objects are on the default layer and default layer is on in the Character layer Manager under solid object layers. Zooming will collide and not go through objects. Character Fader is turned off and fader on objects off. What else am I missing? Thanks.

I set my collision radius up to 2.0 and then I realized that the camera will collide with my NPC which is also on the Default layer as the walls are. So not sure whats going on here.
 
Last edited:
Is this related to your previous thread?


If you can tell me how to reproduce within a fresh project I'll have a better idea.
 
No this is different. I had a data loss and had to reinstall the new controller. I made sure not to make the same mistakes. I've tried making a new camera at default settings and it still just goes through the wall. I haven't been able to reproduce with a new project.
 
Have you tried the suggestions from that thread? It's really hard to say without being able to reproduce it.
 
Have you tried the suggestions from that thread? It's really hard to say without being able to reproduce it.
Yeah its why I put the break points in to see what the ray casts are doing. They are not hitting the walls. I did discover yesterday that when two walls meet together to make a corner the camera collides into the corners and works like its supposed to. Its only on straight walls. I need to test other levels to see if this is just level 1 or if it does this on all 5 levels. I think I remember it doing this on another level a couple weeks ago but I am just going to have to test that Ive slept too much since then and that was the first time I was noticing this issue. I thought it was something to do with the layers since the NPC was hitting but not the walls. But now the corners are hitting and just not flat straight walls shoots that theory down. One thing I am doing different this go around is that the camera is a child object of the player. I have disabled that camera and put in a new camera that isnt a child and still has the same problem. Can the camera be a child object in a prefab? If I could recreate it I could probably fix it, I figure its something I have miss clicked and its some setting but I havent been able to find anything. This time its not game breaking like before because the walls are there and when the camera pivots it only sees a small section of the other room and its not a good view to see hidden things. But it didnt do this before. I did update unity yesterday I was running the 19 version and just got the 21 and that didnt fix it. I am running 3.05 of the controller is there a newer update for that? I guess I might look at that next. When this was all working properly before my crash I was just running unity version 16. Thanks for the help and ideas, Ill keep looking.
 
I will work on getting the camera as its own object. That will take some changing on my end. *I have setup a new camera this way for testing and didnt seem to fix this issue but heres hoping! Thanks.
 
Last edited:
I have changed things around so the camera is its own parent, not a child object. I have updated to 3.08 and the 2021.3.21 version of unity and the camera still will rotate around the character and then through those walls. Im not sure what the difference is now that is causing this issue.
 
Without being able to reproduce it within the demo scene makes it really hard for me to debug. With that said, if you got it working before then it does sound like it's a setting that has changed which just requires you to reset it.
 
Ok Im still not for sure on this but tonight I have noticed one thing on lvl 1 and when I set the tag of player right and zeroed the cameras position in the editor and got the camera as its own object, my lvl 2 is working properly now. Now back to what I seen on lvl 1. I set the collision radius up from .1 to 1, now as Ill be walking down a big open area the camera acts like it hits something and ducks down. Im thinking somehow the camera is physically in a different location than what it is showing/should be at behind the player?
 
When there is a collision issue most of the time it's because people adjust the Anchor Offset rather than the Look Offset. The collision check is determined by the ray between the (Anchor Offset + Look Offset) and the (Anchor Offset). So if this anchor offset is outside of the bounding box then the collision will not be registered.

The camera does not store a different position for collisions compared to its rendered location.
 
Yeah thats what I did the first time. But this time I havent adjusted that. Zooming works right, while if that anchor offset is changed the zoom doesnt work right. Why I thought it was a layering issue at first. Seeing the camera move like that in an open area its colliding with something making it somewhere else like the anchor offset is off. I thought of something earlier, I used to have code that would put the camera as a child of something else. Im going to go through my 20k+ line of code in that file and look for any old code that was forgotten about. One of the first things I did was make a new camera and start from scratch awhile back but it still does this on lvl 1. Ill keep looking, thanks!
 
I got it! So I have been battling random changes happening inside my unity editor save. At first I thought it was just as I updated Unity random things would change or be reset. Well I think I tracked my problem down to my keyboard is sending random keys at times. So as I would click on things in unity it would send a random key and reset something I wouldnt notice since I wasnt typing anything. Now with that being said my avatar, on some levels, got set to default instead of being on the character layer. This seems to be fixing the problem of the camera not colliding with things. Thanks for the help!
 
Top