Cinemachine version: 2.8.4
Unity version: 2020.3.22f1
Cinemachine is a great tool for camera controls, but when I prefab a freelook camera it quickly becomes nightmarish. Previous I encountered this error and it permanently corrupted every subsequent camera in the scene. This means that even when creating a new Main Camera with a cinemabrain component, the “Live camera” on the component would be set to TopRig, making it impossible for me to even create a new camera.
Updating from scratch to the latest version of Cinemachine seemed to work for a few days. It was just this morning that I even ran through my scene and all went perfectly well. But then it happened again. Attached is the error: “Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject: ‘BottomRig’)”. I had prefabbed this a few days ago, and suddenly just clicking the prefab in my project folder caused the problem. It then sets three rigs into my hierarchy.
This also removes the usual controls for camera rigs from the CinemachineFreeLook component.
I’ve asked around in multiple places for help but could not get any responses. How does this error happen? How do I move cameras between scenes (should I set up new controls each time? :/)? What can prevent this error and how can I conduct myself so that my camera works reliably?
Components used on the cinemachine freelook camera:
- CinemachineFreeLook
- Cinemachine Input provider
- Cinemachine Collider
- Cinemachine Impulse Listener
- Playmaker FSM (just a simple Get Owner so I can set it to global)
Any advice would be immensely helpful.
We are aware that sometimes people encounter issues when using FreeLook prefabs. However, we are not able to reproduce these errors when we try. If you can give us specific repro steps it would enable us to fix the problem.
I wish I could.
The prefab worked fine for two days, and I even ran my game repeatedly while building a new area. I never left the area, never added scripts, I only added more objects and sculpted terrain. Simple, basic unity editor map building.
I hit play, it’s fine. I test it every 30 minutes, it’s fine. Then suddenly I test it again for the 10th time and it wasn’t fine.
All I can really say is that you at the very least need to reboot Unity for it to break. How many times, who knows?
Are you saying that you bring it to a state where it works, then just test it a bunch of times (without editing the prefab or its instance in the scene), then suddenly it stops working?
Possibly irrelevant:
Originally I had the error on an older version of Cinemachine. It broke the Cinemabrain component permanently by putting TopRig as a live camera as soon as you hit play. Updating helped for 2 days. It doesn’t break as drastically but it’s still unusable.
Then, it broke itself with no apparent trigger. I was only editing a scene. At most I moved between scenes (both of which contain the camera), I moved the character around but did not touch anything on the component nor did I change settings.
I can’t get the same instance or its prefab to work again, but I can get a copy of it to work if:
- The prefab breaks, it gives the red error, it pastes TopRig, MiddleRig, BottomRig into the hierarchy. Repeatedly.
- The prefab loses its Top Rig, Middle Rig, Bottom Rig options
- In Play Mode and ONLY in Play Mode, the Top Rig, Middle Rig and Bottom Rig options are added again
- If I drag & drop the FreeLook camera from Play Mode into my project window (aka prefab it), I get a fully functioning prefab. No errors. But for how long, I can’t say since I’ve only been testing off and on (and I have a project to work on!).
CTRL+D on the original prefab produces a copy that has its rigs but it loses them as soon as you click away.
Is this still a problem in newer versions? I’m still using 2.8.4.
It happened again. We are now months later without a single occurrence, and I only noticed it happening just now when clicking the prefab in my project window. In case it’s still a problem, the only thing I changed was the Near Clip Plane.
Exact steps:
- Launch play mode
- During play, I tried to change the near clip plane on the main camera, but Cinemachine won’t allow it
- A few mins later I figured it out, changed it on the cinemachine cam
- Saved project, it was like 2 am. Woke up today, launched, clicked prefab in project window, and it did the error again
If this bug has been fixed in newer version, ignore this and maybe let me know so I can properly update. Currently I’m unpacking all my cameras when scenes are finished, so that no bug with the prefab can affect my game in any meaningful way.
Thanks for your persistence. This is a very frustrating issue. We have made some pre-emptive changes in 2.9.0-pre.7. Hopefully they will address these issues, but we can’t be sure because we can’t reproduce them reliably.