Setting up/Configuring Cinemachine at runtime?

Really REALLY like what I have been seeing with Cinemachine, and while I haven’t yet jumped into it, I definitely plan to. It will be absolutely perfect for a part of my game if I can get it to do what I need.

How much of Cinemachine can be manipulated at runtime? A large part of my game is actually designed for content creators, and so I have a planned system in my game that lets players set up camera shots on a rudementary timeline. Nothing as in depth as a NLE, or even as in depth as what Unity provides, but something along the lines of “At time X cut to Camera Y”. I thought I would be writing a lot of this camera system myself, but now I am eyeing Cinemachine to do it.

So how robust is the runtime API for this? Can the timeline sequences I have seen in the demos be setup programmatically at runtime? Can I allow a player to essentially setup a camera with framing and some settings and then drop that into the Cinemachine timeline?

Yes to all of the above. Gregory has completely opened it up so you can customise and extend it however you wish.

A really powerful way of working is to trigger Timeline sequences from code/game events/whatever and put your camera switching/blending timing in there (and anything else!)

Otherwise, simply turning Cinemachine cameras on/off based on whatever events will trigger cameras and they will blend/cut based on their Priority and the Default or Custom Blends.

We’ve spent a long time designing these features as it can be very powerful and versatile. You can easily setup a state machine arrangement - code turning cameras on and off - and they’re all managed appropriately due to the priority and custom blending.

For example, on a game I worked on years ago, we had 20+ Free Look rigs just for the character’s localmotion system. They were triggered by animations and game events, a big controlled sea of cameras blending between each other.

Character jumps - blend to a slightly different rig which lets the character go higher on the screen
Enemies approach - blend to a further back rig
Run through tunnel - blend to a close-in rig
Injured - get closer and put some handheld noise on the cameras
You get the idea - 20+ cameras all blending around to best suit what’s happening

Cameras can really compliment and reinforce gameplay. We’re trying to make it as easy as possible for you to build sophisticated camera systems to support whatever you’ve got going on.

6 Likes

In Unity the states are closely tied to animations aren’t they? We probably won’t be using those as our states are mostly not tied to animation.

The above things weren’t only states, they’re really just concepts. The priority/blend tools allow you to craft the camera behavior by just activating cameras through code or anything else.

Sorry for the late reply, but I have a related follow-up if you don’t mind: for my use case I’m calling camera commands from an external scripting language, and most of the utility I need comes in the form of “Transition to camera with blend style over s seconds”. I already have a complete cutscene system written and tested, so refactoring everything to work with timelines and inspector-configured blend lists isn’t practical. Am I correct that the intended way to do this in code would be to cache a reference to my CinemachineBrain, create a custom CinemachineBlendDefinition for every combination of cut and curve/timing I want, then do something like the following?

        CinemachineBlendDefinition someCustomBlend;
        CinemachineVirtualCamera currentCamera;
        CinemachineVirtualCamera newCamera;
        CinemachineBrain myBrain;

        myBrain.m_DefaultBlend = someCustomBlend;
        newCamera.gameObject.SetActive(true);
        currentCamera.gameObject.SetActive(false);

@Sendatsu_Yoshimitsu You could do that. It should work just fine.

Awesome, thank you very much for the quick reply :slight_smile:

Ah! Adam_Myhill and Gregoryl! You guys are awesome and have helped me so much! THANKS.

But how to know when the blend transition is finished?

@conceptfac You can check CinemachineBrain.IsBlending