Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Using Cinemachine Dolly path in v2.0

Discussion in 'Cinemachine' started by Adam_Myhill, May 17, 2017.

  1. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    187
    While the documentation is being finished, I thought it would write a quick post on how to use the new Dolly path feature in Cinemachine v2.0

    It allows you to create a very smooth path for the camera to go down and you can animate the speed or have the camera 'Auto follow' the subject. You can even auto follow the subject and animate a little offset so the camera goes a bit further ahead or behind, driven by a curve in Timeline. Neat!

    Install Unity 2017.1b3+ You must be above beta 3

    Install Cinemachine 2.0 There's a link to v2.0 from the v1.1 on the Asset Store too.

    If you into fantastic postfx, get the Post Processing Stack

    Open your scene and Intialize Cinemachine by going Cinemachine->Create Virtual Camera from the top toolbar. You'll see that a CM 'Brain' is created on the main Unity camera. This is where all the camera mojo happens and it has some global settings.

    Create an empty object in your hierarchy. Call it 'CM dolly path of wonder'

    Add the CM Path component. Search Path.
    upload_2017-5-17_17-25-1.png


    Add some waypoints. Note you can add more later, delete and even rearrange them.
    Note I increased the values of X for each waypoint.
    upload_2017-5-17_17-26-58.png

    You can also adjust the path in the scene view. The extra set of handles per waypoint are the tangent handles.
    upload_2017-5-17_17-28-47.png


    Now select a CM virtual camera. Set the 'Body' to be Dolly and drag your new path object into the path slot.
    You probably want the camera to Look At something and if you want to use the Auto Dolly, then have it Follow something too
    upload_2017-5-17_17-33-22.png

    If you're not going to use Auto Dolly, then animate Path Position any way you want. It animates really nicely from Timeline, just drag the virtual camera onto Timeline and say Animate

    Animating Path Offset gives you control of being a little ahead or behind, etc.

    Boom!
     

    Attached Files:

    Last edited: May 17, 2017
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,171
    Look at them gizmos - nice!
    Can path component be used for other things? Like moving enemies in a SHMUP for example?
     
    Alverik likes this.
  3. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    300
    Awesomeness! thanks for this. It's something I've been wanting for a while and it works really nice :)
     
  4. ArthurT

    ArthurT

    Joined:
    Oct 26, 2014
    Posts:
    63
    That's fantastic! Wasn't even aware there was a Dolly path feature implemented in CM 2.0.
    I would like to suggest the ability to set the current editor camera position and rotation into the selected path for quicker set up.

    Unrelated, I think it would beneficial for all of us if it's a possibility for the Cinemachine codebase being on Github, where any of us could do a PR to make improvements where needed. :)
     
  5. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    187
    @ArthurT there's even more lurking in CM 2.0 which people don't yet know about. The documentation task is rather enormous.

    Github.. Lots involved with that idea. Eventually CM will be delivered by the Unity Package Manager. You might make an improvement but someone else may not and we'd become code reviewers and gatekeepers. There's a lot of touchy stuff in there which has crazy knock-ons which one might not expect.

    Think of all the systems and the order of operations. We auto compose on some target, then there's the dutch rotation, then there's the noise, then the subject goes over top which would make for gimble-lock hell while blending to a totally different camera setup - yet it all works. Touching just one of those systems can cause weird results in places you wouldn't expect, we've seen it many times and we're the ones who made it.

    That said, if you've got ideas on improving something, please let us know or try the change locally and let us know how it goes.
     
    Alverik and laurentlavigne like this.
  6. caixiang

    caixiang

    Joined:
    Dec 2, 2016
    Posts:
    4
    can we configure rotation on cinemachine path node, not only position?
     
  7. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    187
    Hi @caixiang CM dolly path is a 'Body' component, which means that it just moves or translates the camera. 'Body' components only to translations, 'Aim' only do rotations. We've separated these two systems for a number of reasons.

    So if you want to configure rotation, use an appropriate Aim method:
    - Hard Constraint Look at a fixed point in the world, or keyframe animate the camera's aim
    - Composer Pick a target and let Cinemachine do the animation based on your compositional direction !
    - Group Composer Target a group of objects - you need to target a Group Target Camera object for it to work

    upload_2017-7-5_14-1-17.png

    Note - these examples are from Cinemachine v2.0 - https://www.assetstore.unity3d.com/en/#!/content/79898 which works in Unity 2017.1
     
    Alverik likes this.
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    297
    @caixiang Sorry for the delayed response - I was on vacation and just came back.

    Although rotation is an Aim function and not a Body one, we have made a special exception in the case of TrackedDolly. If your vcam is on a dolly, but has no LookAt target, the camera orientation can be taken from the path. This is how you would set up a rigid camera on a track. Just set the TrackedDolly.CameraUp parameter to "Path", and the camera will take its orientation from the path. Each path node has a "Roll" field which, in conjunction with the path tangent and world up, is used to calculate local path orientation.

    If your vcam has a LookAt target, then the Aim component will override the camera orientation set by the TrackedDolly component.
     
    laurentlavigne likes this.
  9. hensoup

    hensoup

    Joined:
    Jan 13, 2014
    Posts:
    27
    hmm what about multiple dollies? for different paths?
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    297
    The best way to do that is to set up multiple vcams, each with its dolly path. Blend between them to switch paths. Adam showed this in one of his Cinemachine demos.
     
    Last edited: Aug 23, 2017
    Alverik likes this.
  11. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    17
    I am testing cinemachine in 2017.1.0p2, and I noticed 2 problems
    1) AutoDolly does not expand or work.
    2) The CinemachinePath appearance does not expand either.

    --Correction in a raw project it work fine but my existing project had issue. I am guess someone broke the EditorDrawer logic
     
    Last edited: Aug 4, 2017
  12. hensoup

    hensoup

    Joined:
    Jan 13, 2014
    Posts:
    27
    thank you that is working
     
  13. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    54
    How do you get access to a VirtualCamera's dolly component via code? vcam.GetCinemachineComponent<TrackedDolly>() doesn't seem to do it.
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    297
    You have to use the full class name:
    vcam.GetCinemachineComponent<CinemachineTrackedDolly>()
     
    Alverik likes this.
  15. Dreamrocket

    Dreamrocket

    Joined:
    Apr 27, 2015
    Posts:
    2
    Anybody can elaborate how to do this?

    "If you're not going to use Auto Dolly, then animate Path Position any way you want. It animates really nicely from Timeline, just drag the virtual camera onto Timeline and say Animate"

    I am trying to animate my virtual camera body to make it move along the dolly path across time regardless of the position of its target. Should have been simple, but I have spent two days digging and dragging inside the unity editors.

    The last thing I'd like to do is change the source code to expose the Path Position, and write the animation code myself
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    297
    Path Position is already exposed, and you animate it the same way you animate anything else from timeline:
    1. Create an animation track for you vcam (how? either create a new timeline for it, or drag it onto an existing timeline and select "Animation Track" from the popup that appears when you drop it).
    2. Hit Record on the new track (the little red button)
    3. Put the vcam in the inspector, and set a value for the path position, inside the "Tracked Dolly" section. This creates a keyframe at the current time (the field goes red to show that it's being controlled by timeline)
    4. Drag the timeline Current Time bar to a different time.
    5. Set a different value in the Path Position field in the vcam inspector. This creates another keyframe at the new time.
    6. Repeat for as many keyframes as you like
    7. Stop recording.
    8. You now have an animated dolly.

    upload_2017-8-23_8-1-53.png
     
    Alverik likes this.
  17. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    187
    @Dreamrocket this video shows it in action:
    as well as animating the composition of the camera while it's being pushed down the dolly track via Timeline