I’m using a Target Group to make an orbiting camera look at both the player and at the enemy the player has locked onto.
I have a Deoccluder on the camera so that it doesn’t go through walls. This works great when there is no target, and thus the camera is looking at the player’s head.
However, when I lock a target, the Target Group winds up sitting between the player and the enemy. If a pillar is between the two, the Deoccluder can abruptly move the camera in very close. It thinks that it’s being occluded from its LookAt target because the target winds up inside the pillar.
Ideally, I would make the camera not use the LookAt transform, and instead just use a specific transform to do deocclusion. So, the camera would try to move in-bounds towards the player, no matter what the camera is actually pointing at.
Is anything like that possible? If not, it’d be a really nice feature to have!
I’m looking at modifying CinemachineDeoccluder right now. There are lots of places to change, but I think I can make it work 
Oh, wow, that was easier than expected!
I replaced every reference to state.ReferenceLookAt with the position of my “override” transform in CinemachineDeoccluder (except for one in the IsTargetOffscreen method).
It’s working like a charm. The camera no longer freaks out when an obstacle gets between the player and the target. It also behaves way better when locking and unlocking a target near a wall now.
So, there’s a solution if anyone else is interested in doing this.
Very nice. I hope you didn’t actually mod the CM code, but instead made a custom Deoccluder extension by copying the code and applying your mods.
Yes, I did make a copy.
I did have to embed Cinemachine, though. I originally tried to just make a new script in my Assets folder and implement it there, but there were a few issues:
- CINEMACHINE_PHYSICS is not defined in the default assembly, so I removed the #if directive
- RuntimeUtility.GetScratchCollider is internal
- The Documentation class is internal
Only the second point was a show-stopper. I didn’t see a clear way to get my script into the Cinemachine assembly; thus, I embedded the package.
Thanks for the info. We’ll look into fixing these items.