Using Cinemachine Dolly path in v2.0

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.
3073119--231080--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.
3073119--231082--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.

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
3073119--231086--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!

3073119--231085--upload_2017-5-17_17-31-9.png

4 Likes

Look at them gizmos - nice!
Can path component be used for other things? Like moving enemies in a SHMUP for example?

2 Likes

Awesomeness! thanks for this. It’s something I’ve been wanting for a while and it works really nice :slight_smile:

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. :slight_smile:

@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.

2 Likes

can we configure rotation on cinemachine path node, not only position?

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

Note - these examples are from Cinemachine v2.0 - Unity Asset Store - The Best Assets for Game Making which works in Unity 2017.1

1 Like

@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.

3 Likes

hmm what about multiple dollies? for different paths?

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.

1 Like

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

thank you that is working

How do you get access to a VirtualCamera’s dolly component via code? vcam.GetCinemachineComponent() doesn’t seem to do it.

You have to use the full class name:
vcam.GetCinemachineComponent()

3 Likes

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

Path Position is already exposed, and you animate it the same way you animate anything else from timeline:

  • 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).
  • Hit Record on the new track (the little red button)
  • 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)
  • Drag the timeline Current Time bar to a different time.
  • Set a different value in the Path Position field in the vcam inspector. This creates another keyframe at the new time.
  • Repeat for as many keyframes as you like
  • Stop recording.
  • You now have an animated dolly.

3193451--243944--upload_2017-8-23_8-1-53.png

4 Likes

@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

I created my first Cinemachine and Time Machine combo today. The normal CM cameras work well, however, the dolly track doesn’t do much. I did this:

  1. Created an empty object (called CM Dolly Path)
  2. Added Cinemachine Path script to it.
  3. Added waypoints (0,1,2,3).
  4. Dragged and repositioned the waypoints in my scene.
  5. Added CinematicShot clip to my Timeline
  6. Created CM camera.
  7. Dragged a gameobject to Look At.

Any idea where I am going wrong? The first 2 camera shots (not dollys) work with no problem, then the dolly camera is switched to but does not move through the waypoints. Any assistance appreciated thanks.

The CM camera must have “Tracked Dolly” in the body component, with the path field set. The camera’s position on the track is controlled by the “Path Position” field. You can animate that, as explained here: Using Cinemachine Dolly path in v2.0 - #16 by Gregoryl

Thanks and sorry I forgot to add that step, yes I have the CM vcam1 body set to Tracked Dolly and the path is set to the waypoints object. I have Path Position at 0 so that the camera begins at the first waypoint at the start of the bridge. I actually used this thread (and Adams Unity Cinemachine video) to set it all up.