Why is my ClippedCamera clipping?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AmaraAngel

Currently I’m trying to set up a third person camera, which I’ve done by having a Spatial node in the middle of my character and a Camera as a child with a script that rotates the Spatial node with mouse movements. Currently however the camera keeps clipping through objects and walls, which I don’t want. Apparently ClippedCamera is what I’m supposed to use for this, but it doesn’t really seem to work. When walking against a wall it collides with it a bit but then when walking too far the camera ends up going through the wall anyway. How am I supposed to solve this?

This is what the clipped camera looks like in the viewport
ClippedCamera Position

This is what the tree looks like

And this is what the properties of the Clipped Camera look like
I’ve also tried setting the margin to its maximum but that didn’t help either.

Does anyone know how to stop the camera from clipping?

I’m inclined to think that the camera goes through the wall because when you rotate its parent, you are indirectly setting its position to be at some distance from the character. When you get too close to a wall, that distance is large enough for the camera to be PLACED beyond the wall, and it ends up thinking that it has no constraining to do. It doesn’t seem know what point in space it is looking at either, there isn’t even a distance parameter on that node (which is also not documented). Or maybe it’s a bug?
Although, I could be wrong, I never used that node, I don’t know how it is supposed to be used. So far I did this system by raycasting from the character directly rather than having parent/child.
You could post your problem on Github because to me it’s either a bug or a documentation problem.

Edit: ok that camera takes its parent’s global position as target point so your setup should be correct… still not sure where it gets its regular distance from. Is it margin? Maybe you should increase it or something?

Zylann | 2019-07-08 12:57

I’ve already tried setting margin but it doesn’t really seem to do much, if not anything. I’ve tried having a raycast from the character but I had a bit of trouble with that. I guess I’ll have to try that again.

AmaraAngel | 2019-07-11 16:25