Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Simple camera path follow - without lookat - not possible?

Discussion in 'Cinemachine' started by newguy123, Jul 6, 2020.

  1. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Hi Guys

    I want a very simple movement of my camera following a predetermined path, without lookats etc. I can't find a way to do this with cinemachine. I looked at the Dolly on Track, but it requires a lookat to work.

    I just want a simple camera movement where the camera looks in the direction it is travelling....
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    The dolly works without the LookAt.
    The AutoDolly feature requires a Follow target, but you don't have to use that.
    You can animate the m_PathPosition property to move it along the path, either with an animator, or with a script.
    Alternatively, you can use the CinemachineDollyCart behaviour - it has a speed you can set.
     
    newguy123 likes this.
  3. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    How do I get my camera to follow the CinemachineDollyCart?
    I created a CinemachineDollyCart but it didnt create a virtual camera. Do I just somehow get my maincamera to follow the CinemachineDollyCart?
     
  4. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    • Cinemachine > Create Dolly Track with Cart
    • Cinemachine > Create Virtual Camera
    • Make the vcam a child of the dolly cart
    • Zero out the position and rotation transform values of the vcam (though maybe set the Y position of the vcam a little more than 0).
    • Select the dolly cart and set its speed to 1.
    You can alternatively get the same result by NOT childing the vcam to the cart, and instead setting the cart as the "follow" object. (You said no following, but this will affect the position, not the aim). With Body set to Transposer, set the follow offsets to something like 0, .5, 0.
     
    Gregoryl likes this.
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    If you do make the vcam a child of the cart, make it passive by setting the Aim and Body to DoNothing.
     
  6. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Got it working. Thanks @marc_tanenbaum and @Gregoryl

    What's the math behind the speed parameter? I'm trying to work out what speed setting to use if I have the length of my path and I want it to travel the length of the path over a certain timeframe
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    It's m/sec. So desiredVelocity is pathLength / desiredTravelTime.
     
  8. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Thanks, that makes sense.

    I have the next issue and I'm not sure what I'm doing wrong @Gregoryl
    When I press play up top the editor, the camera animation plays and it follows the path.

    However, if I press play in Timeline, the view is unchanged

    upload_2020-7-9_1-49-43.png
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    The dolly cart is self-animating when in Play mode. When you press the little play button in timeline, you're not entering Play mode - you're just previewing the animations encoded in timeline. Instead of putting a velocity in the cart, you can animate its position directly in timeline - that way the timeline has control of it and you won't need to enter Play mode to see the movement.