Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Cinemachine extension pixel perfect adds a camera component that ignores confined space

Discussion in 'Cinemachine' started by iluvpancakes, Sep 6, 2020.

  1. iluvpancakes

    iluvpancakes

    Joined:
    Jul 19, 2020
    Posts:
    18
    Basically the title, been searching but did not find a solution pertaining to this in particular. When I only have Cinemachine running on my 2d project my virtual camera is following the player and respecting the confined space assigned. As soon as I add the extension pixel perfect it adds a camera component and everything goes haywire, especially the fact that it totally ignores the confined space assigned.

    This is what happens when i add the pixel perfect extension:
    confined cine.PNG
    The camera just follows the players no matter where it moves in relation to the confined space (the green edge is the edge of my background tilemap and it's the collider defining the confinement).

    If I simply remove the pixel perfect extension and the added camera component that it adds with it:
    confined cine2.PNG

    It stops moving when I approach the border and I can not see "outside" of the confined space. As intended.

    Any ideas?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    The CinemachinePixelPerfet extension won't add a Camera component. Are you sure that you're adding a CinemachinePixelPerfect extension?

    Can you show images of your inspectors?
    What version of Cinemachine?
    What version of Unity?
    Is it an HDRP or URP project?
     
  3. iluvpancakes

    iluvpancakes

    Joined:
    Jul 19, 2020
    Posts:
    18
    I am sure you are right that I was doing something incorrectly. I however scrapped this project and gave up on 2D in favor of 3D so I do not have the project files anymore.

    If I recall correctly I had an issue where I could not add a Cinemachine pixel perfect extension without adding the pixelperfect component first (which added the camera component). This might very well have been the result of my own ineptitude though I am sure.

    Thank you for the reply though.
     
    Gregoryl likes this.
  4. therealressii

    therealressii

    Joined:
    Oct 28, 2020
    Posts:
    2
    Hi, I'm new to Untiy and recently I've also ran across this issue with my game where the Cinemachine Virtual Camera won't confine to the polygon collider. This doesn't happen with another game I've made from a tutorial, the only different between the two are that, in the game I'm working on right now, the Cinemachine has a Pixel Perfect Camera on it which adds its own Camera component in the inspector. So I think it has to do something with the Camera component, but you can't remove it due to the Pixel Perfect Camera relying on it to work.



    The version of Unity is 2019.4.13f1 and the Cinemachine version is 2.3.4
     
  5. therealressii

    therealressii

    Joined:
    Oct 28, 2020
    Posts:
    2
    Oh wait I literally just found a solution after tinkering with the Pixel Perfect Camera component, the solution was just adding it to the main camera.
     
    Gregoryl likes this.
  6. Veet

    Veet

    Joined:
    Jul 10, 2019
    Posts:
    1
    Hi.

    Just in case someone is still struggling with this very specific, PixelPerfectCam-related issue, I found a workaround.

    First of all, let me specify that in my case, the colliders did work when a new scene was loaded/the starting scene was reloaded. The cinemachine confiner 2D only seemed to ignore its bounding shape when the first scene(as in: the when I entered play mode from) was first loaded. After that, everything worked perfectly fine.
    I am also 100% certain the issue is related to the pixel perfect camera, as everything worked fine by simply turning it off.

    So, here's my workaround(I feel like it's bad practice, I refuse to call it a proper fix):

    For some reason, pixel perfect camera component messes up the cinemachine confiner 2D.
    I ended up using the normal cinemachine confiner instead: set Confine Mode to 2D, then toggled on
    Confine Screen Edge(this option didn't show up on my cinemachine confiner 2D).
    I used the exact same polygon collider 2D I was trying to use when I had this issue.
    It now works. Idk why that is.

    I want to reiterate that this was a bit of a desperate attempt to fix this, after trying out pretty much any solution I could find on tons of already existing threads. Make sure everything else in your cameras/colliders/physics setting/whatever else you have going on has already been set properly. I don't think this will help you otherwise
     
    antoinecharton likes this.