How to avoid camera clipping through objects

Hello, Im trying to stop camera clipping through walls and nothings seems to work.
I’m using cinemachine orbital follow, rotations composer, deoccluder and camera offset.

  1. I tried to use decollider, it didnt seems to change nothing.
  2. I read that offsets doesnt work with decollider, so how you can achieve camera offsets without clipping problem?
  3. My cinemachine follow a player camera root.

I’m trying to give the player to apply X and Y offsets and zoom option.

How to make offset on Y works without clipping like this clip bellow?

Are you referring to this momentary clipping, on the right side?

I’m not sure it’s possible to completely avoid this. I suppose you are having a MeshCollider on that tree. It would be best to use a collider that’s slightly scaled up or even a primitive (capsule) collider that hulls the entire mesh if you want to avoid this entirely.

For simple geometry I found that the default 3rd person camera collider gave better results than the Deoccluder. Maybe it’ll work better for you as well.

You don’t need an orbital camera for this kind of third person camera controller where you can pan around the character, you just need to not track the actual character but a child object. You can then use this camera target if you want to implement the typical 3rd person “forward input rotates character back to camera’s forward” feature.

You need to reduce the camera’s near clip plane when the camera is near the player. Doing this may result in artifacts (z fighting) in the distance and so you may also need to reduce the far clip plane.

Perhaps Cinemachine already has an option to do this for you automatically. I dunno, I’ve never tried it.

In the video, the camera is working perfectly, Im trying to reproduce this on my system, that is working everything perfectly, but this: if there is an offset to the cam, the object that the cam is following goes through the objects (like walls), and the cam goes aswell.

In the video I shared above, the aim returns to a non offset position, as the the player approaches the wall, preventing clipping.

I even tried to apply the horizontal offset on the rotation composer and it worked only to a certain height, when it returns the player to a non offset position as the cam goes higher.

My cam alreaey follows a player child ‘player cam root’.

When I asked here before and I explained my system, Gregory suggested that orbital follow would be the best approach, and it is working 100% besides this offset problem.

The clipping without offset on X was already fixed, the problem is when I apply offsets on X axis.

OrbitalFollow + X offset will create clipping problems. For this kind of camera it’s better to follow a different strategy, as outlined in the attached tutorial. See also the ThirdPersonWithAimMode sample scene that ships with Cinemachine, for an implementation that you can take.

Hello Gregoryl! Thanks for the answer, I did change to Third Person Follow with Hard Look At, and now everything is working properly!