camera has curious constant rotation around target in editor mode - 2D project

Hello,

i'm working on a 2D project where my character runs and jumps on planets with faux gravity. I decided to add the cinemachine package to have neat camera tracking but as soon as i implement the virtual camera and set my character as the target, the camera starts rotating around the x axis (i.e. out of the2D plane!) even when i am still in editor mode.

I tried with the last verified cinemachine version (2.6.11) and with the last release (2.8.4) and i still have the same issue.

Could you please help me solve this problem?

Current Unity Editor version: 2020.3.26f1

Thanks!

Hi @NikkiSF! Could you please post a screenshot of your Virtual Camera's inspector?

1 Like

Hi, thank you for your answer, and sorry for the delay.

Here is the requested screenshot:

7877284--1001686--upload_2022-2-8_0-52-44.png

and i also post the cinemachine brain on my main camera:
7877284--1001689--upload_2022-2-8_0-52-59.png

That’s strange, because you only have FramingTransposer in Body, which does not touch the camera rotation, just the position. Camera rotation is usually controlled by an Aim behavior.

Could you send an image of your Hierarchy? I think, you have your vcam parented to your target, which may cause unexpected behavior.

Here is the hierarchy: pretty simple at the moment

7879090--1002103--upload_2022-2-8_16-3-0.png

What is also surprizing is that when i open unity, the camera doesn’t rotate in editor mode. Then if i launch the game, it spins as hell, and when i stop the game, now it spins also in editor mode.

Hmm.. Could you send me a project, where I can reproduce the issue. That'll make it easier to find the cause. :)

1 Like

I tried to recreate the issue in a simpler project but.... it didn't bug this time... I'll try again

Ok, i deleted most of the features of my project and i still have the issue. Here is the zip file
(with only the “Assets” and “ProjectSettings” directories for zip size limitation - do you need other directories i didn’t send?)

EDIT: those files are not enough to open the project and see the problem, i sent you a google drive link.

1 Like

Thank you for the repro project.

What I see is that there is a hidden vcam that CmBrain selects as Live Camera. It's called BottomRig, so I assume it is a remnant of a Freelook vcam.

I could fix the rotation by making CM vcam1 the Live Camera by increasing its priority.

The correct solution would be to remove those hidden gameobjects that corrupt your scene. Probably, the easiest solution would be to create a new scene, and copy over your Hierarchy.

1 Like

Thank you a lot for the diagnostic!

I remember trying to add CinemachineFreelook before the Cinemachine2D, what appears to be the mistake...

So I have a few questions after reading you:
- how can I find a hidden camera that doesn't appear to be anywhere in my project nor hierarchy?
- why can't I simply manually replace the liveCamera in the CmBrain? (I guess that it's just how it works)

You could use this script to print all gameobject to console, that have some kind of hide flag:

using UnityEngine;

[ExecuteAlways]
public class FindAllGameobjectsInScene : MonoBehaviour
{
    public bool findThem;
    void Update()
    {
        if (findThem)
        {
            findThem = false;
            var gos = FindObjectsOfType(typeof(GameObject));
            for (var i = gos.Length - 1; i >= 0; i--)
            {
                if (gos[i].hideFlags != HideFlags.None)
                    Debug.Log(gos[i].name);
            }
        }
    }
}

CmBrain selects Live Camera based on priority. It chooses the highest priority vcam from all the enabled vcams in the scene. The default priority value is 10.

1 Like

Thank you so much for your help!

After some iterations, i indeed saw that 10 was the threshold priority. I could just put 11 but I’ll follow your advice and clean this scene up!

Thank you again

edit: I ran your script and saw a list of unwanted objects. But i still couldn’t find them physically in the project in order to delete them, so I assumed they were childs of my main cam : i deleted it and create a new camera and TADAAAA: no more impostor object !

1 Like