Hi there!
I have a Grid with an attached Polygon Collider 2D to use as Cinemachine Confiner. The collider is the correct size, but still, once I actually move the player with the camera following, the camera goes out of bounds and eventually does stop, but still too far out. This resolves itself immediately as I resize the Game window event by a tiny amount in either direction (see video).
I feel like this could be some problem with the ortographic camera size being updated by Pixel Perfect Camera when starting up Play mode and Cinemachine failing to register this. I have tried LateUpdate instead of SmartUpdate on Cinemachine, but nothing changes… Of course removing Pixel Perfect entirely restores expected behavior, but that’s not really a solution.
Everything relevant should be in the screen capture below but please do ask questions if anything! I just wanna get out of this bind ;_; thank you all in advance!
u96odt
Edit: I noticed that enabling either Crop X and Y or Upscale Render Texture makes it so the bounds behave correctly from the get go. That makes me even more confused, but I’m hoping it is useful info.
Interesting. Would you be willing to send me the test project?
Thanks for the project! The problem seems to be due to a bug in the PixelPerfect component, which is causing CinemachineConfiner2D to think that the ortho size is always 1, until the CinemachineConfiner2D’s cache is reset.
There are a couple of possible workarounds for this:
- Enable Upscale Render Texture on the PixelPerfect component:

- Alternatively, you can add this behaviour to the vcam with the confiner. Set the behaviour’s execution order to be later than default or it won’t have the desired effect.
using UnityEngine;
using Cinemachine;
public class ResetConfiner : MonoBehaviour
{
void Start() => GetComponent<CinemachineConfiner2D>().InvalidateCache();
}
2 Likes
I went with solution #2 and it worked like a charm. Thank you so much!
1 Like
Was this ever fixed in a official release?
Still happening to me on Unity 6000.0.42f1 and Cinemachine 3.1.3. The script worked like a charm and fixed the issue but just wanted to know if there is an official fix for this. Specially taking into account how the documentation says that Invalidating the cache at runtime is expensive.
Thx!
Update on this. It seems like is not just when start to play the game. When switching between actives cameras in blend sometimes it was also failing to get the correct bounds in the newly activated camera.
I have come up with this code for now that seems to do the trick and work. Not sure if this behavior is intended by design or is an error.
[DefaultExecutionOrder(-99)]
public class ResetConfiner : MonoBehaviour
{
[SerializeField] private CinemachineConfiner2D _confiner2D;
void OnEnable()
{
CinemachineCore.CameraActivatedEvent.AddListener(OnCameraActivated);
}
void OnDisable()
{
CinemachineCore.CameraActivatedEvent.RemoveListener(OnCameraActivated);
}
private void OnCameraActivated(ICinemachineCamera.ActivationEventParams activationEvent)
{
_confiner2D.InvalidateLensCache();
}
}