Search Unity

Using Cinemachine Dolly path in v2.0

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

  1. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    Yes there is a setting in the Tracked Dolly component - camera up, I think it's called. Set it to "path", and put "Do Nothing" in the Aim section. That should do it. You can then animate the path position field in the tracked dolly component, either with a script or with the Animation window or timeline.
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,088
    Have you also thought of supporting closed / continuous paths?

    In my specific use case, I'd control movement along the path myself, so if the path goes from 0 to 1, I'd continue with 0 after 1. I'd just have to rely on the path being equidistant or having some method of setting the path position that guarantees that the distance on the path between 0.1 and 0.2 is the same as e.g. 0.7 to 0.8. This is used for a camera that circles around the player and first speeds up, then keeps on circling at constant speed until it eventually slows down and stops (all of this is based on gameplay).

    I'd imagine that for the more common use cases, you'd have to make sure the system understands that sometimes, going from 0.9 "up" to 0.1 (0.2 "distance") would be more appropriate than going from 0.9 "down" to 0.1 (0.8 "distance").
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    Thanks for the suggestions. In fact all the features you mention are already included :)
    • Path has a "looped" checkbox. If checked, the path is a closed loop, where normalized position 0.0 is the same as normalized position 1.0.
    • If you animate the path position in "distance" units, then world distances along the path are the units used to specify a point on the path. If the path is looped, 0.0 position would be the same point as position X, where X is the path length in world units.
    • If you specify a path position < 0 or > path length, position will be clamped if not looped, and will wrap if looped.
     
    Last edited: Apr 9, 2018
    jashan likes this.
  4. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,088
    Very cool! I'm currently in the process of porting our project from Unity 5.6 to Unity 2017.4. We have a pretty decent "Streamer Mode" which is basically a camera system for spectators / streamers / video creation (this is a VR game, obviously, what the player sees is just the player perspective ;-) ). If things go well, we should be able to port some of the features we already have our own custom implementations for over to Cinemachine.

    From what I have seen so far, Cinemachine looks quite awesome and it will be interesting to see how well it works with some of our concepts (e.g. as we have a rhythm game, we have "time" purely driven by audio-time and any camera cuts are based on the rhythmic structure of the music).
     
    Adam_Myhill likes this.
  5. howardboland

    howardboland

    Joined:
    Jun 10, 2016
    Posts:
    2
    Having an issue when changing the waypoints dynamically (e.g. removing - and thus changing the track). The track seems fine but the camera seems to get confused. Anyone else come across this issue?

    I am using the dolly track in a gallery manner - so each waypoint has an associated object - so want to be able to add and remove.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    If you're using distance units then the path keeps a cache for performance. If you change any waypoints you then have to call path.InvalidateDistanceCache() to force a rebuild. Very likely that's your issue.
     
  7. howardboland

    howardboland

    Joined:
    Jun 10, 2016
    Posts:
    2
    Thank you - that worked for me!
     
  8. LezTusi

    LezTusi

    Joined:
    Nov 15, 2014
    Posts:
    28
    Do you guys have by any chance a cinemachine cart that can auto dolly? I'm experimenting with the auto dolly for quite sometime now to make a path constrained character controller. it does work with vcam, but i think it'll be better for the cinemachine cart to have an auto dolly too! :) Thanks!
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    The Dolly Cart is just an example class, to show what you can do with CinemachinePath. It would be quite easy for you to add auto-dolly functionality yourself. Just copy the DollyCart class, and add the auto-dolly code that you can find in CinemachineTrackedDolly.cs. You can see that it just calls a FindNeareastPointOnPath function in CinemachinePath to get the target spot on the track.
     
  10. szanetti

    szanetti

    Joined:
    Apr 1, 2016
    Posts:
    5
    Hi,

    I'm using the track dolly with timeline and everything works fine the first time the timeline it's played. But if I play the same timeline again the camera start from wherever it finished the first time and try to move back to the beginning.

    If I look at the value of Path Position it does restart from 0. It's just the camera that is not forced back to the start position but instead it's smoothly moving back there.

    The camera moving along the track hold both the Brain and the Virtual Camera. The Default Blend in the brain is set to Cut.

    Do you guys have any ides on how to deal with this issue.

    Thanks for your help
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    If you're only using the dolly vcam in the timeline, just disable the game object. When timeline needs it, it will be automatically activated and will snap to the right spot.
     
  12. szanetti

    szanetti

    Joined:
    Apr 1, 2016
    Posts:
    5
    Thanks for the suggestion. I tried enabling/disabling the Virtual Cam, Brain, the dolly object and even the whole timeline but none of them worked.

    Having said that I found a different solution for now by setting the last frame of the dolly position animation back to the starting value. I do this after the cinemachine shot clip is complete. This seems to be working.
     
  13. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    87
    I want a camera to follow a dolly path but I'd like to be able to set the cameras rotation as well as position for dolly waypoints - is this possible?

    Currently I am getting around this with an empty target lookat object which I have to move on a separate animation and have the camera face it. This is a very tedious workflow though; I have to manage the positions of two objects through separate animations and animation controllers. I just want to lerp position and rotation of the camera without having to have a separate target object.
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    Yes, the tracked dolly has the option of initializing the rotation to match the path. Look at the options under Camera Up, something like "take from path" (sorry I'm just doing this from memory now)
     
  15. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    87
    Thanks for the reply Gregoryl. That option does not let me set rotation (at least not for yaw or pitch) though, it just hardwires the rotation to track the camera velocity projectory as far as I can tell. I don't want the camera to be facing in the direction it's moving.

    Please let me know if I've misunderstood.

    I think all I need is the ability to set the camera rotation as well as the position at each of these waypoints in the dolly tracker.

    I actually have already used this nice free asset https://assetstore.unity.com/packages/tools/camera/camera-path-creator-84074 to do this easily but I figured I'd have a go using the Cinemachine so that it was more adaptable for the future.
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    Sounds like you just want to animate the transform of the vcam. You can do that with timeline. Choose "Do Nothing" in Aim and Body for the vcam, and animate its transform as you would any other.

    Certainly you could use the camera path creator asset instead of the timeline to do this. Apply the animation to a DoNothing vcam instead of the main camera, and you'll get all the benefits of working with a virtual camera (blending, noise, impulse, etc).
     
    Last edited: Aug 6, 2018
  17. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    554
    Hello, Im using CinemachineDollyCart and I'm having trouble changing the m_speed parameter through script. I have confirmed that the m_speed value is changed by checking with debug.logs in my helper script but the value in the editor is not changed so the object continues to move at the original speed.
     
  18. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    327
    A few ways to do that. You're trying to lock the camera to the dolly object.

    Create a Dolly Track and Cart.
    Create a vcam
    Have the vcam follow the dolly cart

    upload_2018-9-19_16-42-38.png

    Make the vcam follow the dolly cart
    upload_2018-9-19_16-43-26.png

    Set the camera Body Transposer to Lock to Target
    Position the camera in the cart with the Follow Offsets
    upload_2018-9-19_16-44-18.png


    Set the angle of the camera by adding rotations
    upload_2018-9-19_16-45-38.png

    Voila. There's other ways too but this is probably the easiest
     
  19. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    554
    Is this a bug or am I just doing it wrong?
     
  20. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    There should be no problem changing the m_speed field through script. It's a field like any other, and it is referred to by Update in DollyCart to move the cart. Is it possible that you have another script somewhere that's setting the speed?
     
  21. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    554
    No sir. Also, that file is read only. Could that be the problem?
     
  22. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    Read-only is fine. Can you show me the script where you're setting the field?
     
  23. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    554
    Solved.
     
    Last edited: Sep 20, 2018
  24. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    Looks fine to me. It should work. If it's not working, my guess is that you have something else in your project that's interfering. Why don't you try making a simple project with nothing in it except a dolly cart and this script, and see if it works there.
     
  25. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    554
    Staying up late coding will cost you to make some silly mistakes:D.
     
    Last edited: Sep 20, 2018
    Gregoryl likes this.
  26. Philkrom

    Philkrom

    Joined:
    Dec 26, 2015
    Posts:
    41
    Hi, I would like to make something which seems - to me - very simple. I made a dolly track, animate with timeline the VM cam along the path, so it follows the axis of the path (not tracking any object). I would like to animate in the timeline the rotation of the camera, for instance to avoid, when the path is "climbing" to see only the sky... I tried several ideas (add keys for the vcam rotation, attach the vcam to an animated parent...) without success. Any idea welcome !!!
     
  27. Philkrom

    Philkrom

    Joined:
    Dec 26, 2015
    Posts:
    41
    No answer... Maybe my question is not clear. Is there any way to animate (rotate x - y - z) a camera following a dolly path ?
     
  28. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    Yes. Create a vcam with "Tracked Dolly" in the Body section and "Do Nothing" in the Aim section.

    Animate the Path Position field in the vcam to set the camera's position along the path. If you set the Position Units field to Normalized, then the position value is 0 for that path start and 1 for the path end.

    Putting "Do Nothing" in the Aim tells the vcam to not animate the rotation, allowing you to do it yourself. Just animate the vcam's transform's X, Y, and Z rotation fields from the timeline as you would animate any other object.

    As an alternative, you could put "Hard Look At" in the vcam's Aim, and create a target object that you position somewhere in space, setting the vcams' LookAt to that target. Then, animate the target's position, and the vcam will always look at it.
     
    Philkrom likes this.
  29. Philkrom

    Philkrom

    Joined:
    Dec 26, 2015
    Posts:
    41
    Hi again. Despite my efforts, I couldn't make this working. I contact you via private conversation to give you a link of the short video I made. Hope you can watch it and explain me where I am wrong !
     
  30. Philkrom

    Philkrom

    Joined:
    Dec 26, 2015
    Posts:
    41
    Hi
    I am working on a tour on a 3D map, using Dolly Track+vcam. I have hundreds of waypoints to manage, and I can easily make a list in a sheet with X Y Z values. Does a way to save / load these values in the cinemachine path list exist? Maybe with playmaker arrays ? Another option could be to create null gameobjects at these points, and build the Dolly track with these points. It could be an intersrting option to add a column in the Waypoints list with the name of theses game objects.
     
  31. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    You could write a custom script to read your data and dynamically build the CinemachineSmoothPath.m_Waypoints array.
     
  32. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10
    Hey there. I am struggling to figure out how to do something simple with Cinemachine. I am trying to speed up a very small loop to simulate an idle position. The speed is very slow without. I tried adding a Dolly Track, and using the speed. I set various values, from 0.01 to 10, and nothing seems to work. (It gets very glitchy, and spins around super quick.)

    What am I doing wrong? Cheers.
     
  33. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    I'm having a hard time understanding what you're trying to do. Could you explain a little more?
     
  34. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10
    Basically, I have a virtual camera which is on a dolly track loop. Out of the box, it's very slow. I want to simulate breathing, moving from foot to foot, etc.. Which just requires the loop to be sped up.

    Thanks again!
     
  35. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    is the vcam in a dolly cart? Can you show me the inspector?
     
  36. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10
  37. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    ok, but that's not very helpful. I need to understand what you're animating and how. You referred to "speed". What speed? Is there a cart? How are you animating whatever it is you're animating? What are the params inside the Tracked Dolly section?
     
  38. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10


    Appologies. I *added* the Dolly cart after the fact.
     
  39. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10
    Ah you meant this:
     
  40. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    so... you have a dolly cart and a tracked dolly? How does that work?
    And the cart is on the same game object as the track?
    And that path looks really big... several meters in diameter from the look of it. I thought you said it was a small breathing loop.

    Now I'm more confused than before. I have no idea what you're trying to do, or how you're trying to animate it. Maybe you should start over from the beginning, and describe to me what you want to accomplish, as if I were 4 years old.
     
  41. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10
    Alright, so it worked before I added the Cinematic Dolly Cart. I tried adding that to change the speed, but it didn't work. If I remove that, I get the camera animation I am looking for, but at a much slower speed than desired. It's just a small loop.

    I essentially just want to speed up a tracked dolly. How can I do that?
     
  42. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    How are you animating the vcam's position on the track?
     
  43. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10
    With a Cinemachine Smooth Track.
     
  44. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    When you animate a vcam's position on a track, you must manipulate the TrackedDolly's m_PathPosition field.

    Assuming that the TrackedDolly's m_PositionUnits field is set to Normalized, then a value of 0 corresponds to the beginning of the path, and a value of 1 corresponds to the end of the path. If the path is looped, then beginning and end will be the same point.

    If you want to animate the vcam to loop around the path, then you must animate m_PathPosition linearly from 0 to 1, with wraparound.

    How are you changing the value of m_PathPosition in the vcam's TrackedDolly component?
     
    Last edited: Nov 14, 2018
  45. CodeMankey

    CodeMankey

    Joined:
    Jun 25, 2013
    Posts:
    10
    The Cinemachine Smooth Track is not what does this? I have that, and I have a Tracked Dolly in the body of the vcam body.
     
  46. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    The track is just a track. It doesn't do anything other than exist. The vcam with a TrackedDolly positions itself on the track, at the point specified by m_PathPosition. Someone has to drive m_PathPosition. You can do it with a custom script, or with animation of that field.
     
  47. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    17
    Really loving Cinemachine, but I'm having trouble with the DollyTrack. In other spline tools you can adjust handles in order to define the interpolation of the curve between points. In the DollyTrack there is no such thing. See image:


    I want there to be a hill movement, but I don't want the camera to dip below the y=0 plane. I tried adding multiple points between 2 and 3, but that didn't help. No matter what it wanted to dip below 0. Is there any way I can make sure the camera doesn't go below the floor plane? Or any way to add point/interpolation handles? I want to keep the resolution of the track relatively in the middle to have smooth movement throughout.
     
  48. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,845
    The standard path automatically generates the tangents in order to guarantee smoothness in the higher orders - lack of this becomes apparent when a camera travels on the path and goes around the curves. Without this smoothness the rotations can look mechanical.

    If you don't require this degree of smoothness, you can replace the CinemachineSmoothPath component with a CinemachinePath - this component allows you some control over the tangents at the cost of the smoothness guarantee.

    A third option is to implement your own path component. If it inherits from CinemachinePathBase, then it can be used with Cinemachine. Then the path can be any shape you want.
     
    rtilton1 likes this.
  49. rtilton1

    rtilton1

    Joined:
    Jan 4, 2017
    Posts:
    17
    Thanks so much for the thorough reply! Exactly what I was looking for. Bravo to you and the team for making such a simple yet versatile tool.
     
  50. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    28
    Hi, I heavily relied on cinemachine in my current project but ran into trouble.
    Basically, I'm starting with a Virtual Camera (CamA) that can be dynamically rotated(it's aiming at a target) When selecting a target in the UI the camera is supposed to follow a path through the building to to another virtual camera.

    I set up a tracked dolly camera (CamB) and animated it as described above. Works like a charm. The main problem is the transition:
    If I start the timeline it will result in a undesired hard cut(despite the settings in the cinemachine brain). If I add CamA to the cinemachine Track to blend the cameras (mostly this affects the roation), the blend target position is always the end position of CamB, not the current position on the Dolly Track. This causes a somewhat erratic movement.

    Did I miss anything? How do I make CamA blend to the current position of CamB on the track? Or even better, as the start position is perfectly aligned, is there a way to just blend the rotation over time while the camera is already traveling on the dolly track?