Search Unity

Feedback Cinemachine Virtua Camera transitions need more blending options (in particular speed)

Discussion in 'Cinemachine' started by awiebe, Sep 25, 2020.

  1. awiebe

    awiebe

    Joined:
    Oct 16, 2018
    Posts:
    14
    I've taken the plunge to use cinemachine, and in a lot of ways it's nice to track the player and do physical object avoidance, but it is also still kind of lacking in ways that mean I have to fight it with weird programmatic hacks. A lot of this has to do with how it behaves when changing camera.

    When transitioning from one virtual camera to another without a cut, I need to satisfy the following constraints:

    1. The camera does not move through non physical decorative geometry.
    2. The camera does not turn in such a way as to expose unloaded portions of the level.
    3. The camera does not fly at a vertigo inducing speed across the level

    The easiest way to solve this would be to define a series of cinemachine virtual cameras to pass through on the way to the target, but this can cause problems with 3 because the speed at which a transition occurs is time dependant.

    An alternative is to move the camera to a fixed camera near where I expect the player to when the event occurs, and then execute a preprogrammed timeline sequence. But this is inflexible and still runs into a problem when an event (e.g. x number of enemies defeated) occurs at an unpredictable position in a large arena.

    All I really wanted to do was have the camera move to the destination or sequence of destinations at a fixed speed(with easing). I don't actually want it to move in 2 seconds regardless of its initial position.

    Side Note: It is such a common pattern that I need to go through a blend list and then follow the blend list in reverse that there should be a tickbox to reverse the transition list with a speed multiplier. Though as mentioned I need a blend list that is based on whether a camera becomes active since it reached its destination, rather than holding a position expecting transition time to be fixed.

    ==A use case==
    I've been experimenting with interrupting my player character's controls to display machinima cutscenes about objectives. For example if a button results in a timed platform being released, I freeze the player, swap to a virtual camera looking where the platform will appear, and then move the platform into place. Then return to the player's camera rig, and unfreeze player input.

    The objective camera can be an arbitrary distance away from the player, so a default camera transition time won't cut it.

    I can see in the camera documentation that I could manually set an interpolation time for every single time this happens in my game for every cutscene virtual camera.
    https://docs.unity3d.com/Packages/com.unity.cinemachine@2.6/manual/CinemachineBlending.html
    https://docs.unity3d.com/Packages/com.unity.cinemachine@2.6/manual/CinemachineBlendListCamera.html

    That's certainly a solution, but all I really wanted was a camera that moved at a fixed speed (with easing) rather than setting the duration. I understand that under the hood cinemachine constructs an animation curve for the transition, and in a naive sense those are just a time value interpolating the transition, so the current implementation was the most trivial. But what I really want is to instead define a default any to any camera transition in terms of velocity and have the brain figure out the timing based on that distance (though this might get a bit complicated transitioning between non fixed cameras).

    At the very least if this is too difficult to do in the general case, there should be an article in the cinemachine microsite showing how to construct and execute a custom transition programmatically using information you have about the world.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Thank you for the valuable feedback. You bring up some interesting points.

    1. For the fixed-speed (as opposed to fixed-time) transitions: currently in Cinemachine there is a delegate (CinemachineCore.GetBlendOverride) that gets called whenever a vcam blend is initiated, giving you the possibility to override that blend. You could write a little method that adjusts the blend time as a function of vcam distance, giving you some control over the average speed.

    2. For the blending camera to avoid obstacles: this is a little trickier. Only the source vcams can have avoidance logic - the blended result is just an interpolation of the inputs, so it can in principle go through obstacles. One way around this would be to create a CinemachineMixingCamera, which is a way to expose a continuous controlled blend as a vcam, to which you can add an extension (CinemachineCollider) to avoid obstacles. You have to drive the blend weights with custom code, but this could work well for you given that you want to control the blend speed.
     
    gaborkb likes this.