I am modifying the priority for cinemachine virtual cameras from a script to switch cameras based on script events. But I’m having a problem with the “SaveDuringPlay” functionality as those modifications are saved.
Should I be changing priorities from scripts to switch between cameras to begin with? If so, is there a way to avoid those changes been saved?
You can disable the SaveDuringPlay for any property by adding the [NoSaveDuringPlay] attribute to it. Since the priorities are meant to be changed during runtime, it makes sense to exclude the m_Priority member from SaveDuringPlay. We will make this change in the next release. In the meantime, you can just add that attribute yourself to CinemachinrVirtualCameraBase.cs, which is where m_Priority is defined.
I could use some best practices guidance with the second part of the question. What is the concept behind switching cameras based on play, not the timeline, for example using a trigger collision, or a script event to switch cameras?
I’ve been through the documentation several times and several tutorials. It doesn’t seem like switching cameras like thisa focus for CM, but is not intended to be used like this?
@keithkid The Priority system of controlling the current camera during gameplay is central to Cinemachine. The idea is that a game event (could be a trigger, a script, a UI control, a timer, anything you like) triggers the running of a script which enables/disables vcams, or modifies their priorities. The vcam with the highest priority (or the most recently-enabled one if multiple vcams have the highest priority) will drive the Unity Camera.