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,844
    You can stop the timeline from making a hard cut by setting the ease in/ease out times on the clip. Giving a CM clip an ease-in time will cause the camera to blend from the current active vcam to the clip vcam, over the length of the ease-in. Similar for ease-out.

    upload_2019-1-17_7-49-45.png
     
  2. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    28
    I found a workaround by eliminating the cinemachine track altogether, just animating the path value with timeline (I might as well lerp it by code, there is no reason to use timeline any more) and switch the VCAMS using the priority value. Losing the nice previewability of the flight, but it works. Still, this looks like a bug to me, this should work with a cinemachine Track...
     
  3. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    28
    Oops, missed your post. Thank you...
     
  4. Adam_Myhill

    Adam_Myhill

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    327
    @BinaryX Cinemahine separates the ideas of translation, or body movement, and orientation - camera aiming.

    Auto dolly track will follow - move the camera - based on whatever you put in the follow slot. Look at is where the camera orients / aims at. That can be an entirely different thing. You can look at an object further ahead on the track, or the front of the car you're in or.. whatever.

    You could also put 'Do Nothing' in the Aim and have the camera hard locked to the cart and it will inherit all the cart's motion and always be 'looking forward'.

    Lots of options!
     
  5. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    28
    @Gregoryl : I'm still somewhat puzzled, the blending is still behaving weird.

    Current Virtual Camera Setup:
    VC A: Start Camera, rotation dynamic.
    VC B: Tracked dolly cam aiming at a lookAt target
    VC C: Target Camera, also dynamic

    The endpoints of the dolly path exactly match the positions of VCA and VCC.
    I've set up a timeline that will blend from the start camera to the tracked dolly, animate the dolly ride and in the end blend to the target cam (I switched priorities inflight by code, but the same motion appears when I put the cameras on the cinemachine track) The blends basically only exist to adjust the rotation to the current dynamic positions at the end points.

    When I run the application the camera position goes crazy during the ease out blend, it looks like cm uses the starting point of the path for the blend instead of the current camera position) This does not happen when I scrub the timeline manually! I can't figure out what's causing this behaviour.

    Download a Screencapture (WMV)
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    Can you enable the Debug Text on the Brain so we can see what cameras are getting enabled and when?

    When you change the priorities, CM is blending from vcam A to vcam B. The timeline is overriding that, but the blend is still happening under the hood. Depending on when you switch the priorities in-flight, you could be seeing the tail end of the blend vcam A to vcam B. An easy fix would be to add a custom blend setting that forces a cut when transitioning vcams A to B. Make sure you switch priorities after the timeline clip has faded in, but before it has faded out.
     
  7. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    28
    Yes, that was it... I have LOTS of virtual cameras in the project. So instead of creating custom blends for any possible combination it was easier for me to take control over the CinemachineBrains default blend value from my CameraManager and switch it to zero during this kind of transition. But that did the trick, thank you.

    (Edit:By the way, the oder of the camera list for custom blends seems a bit random, alphabetically would be way better....with lots of Cams in the Scene it would have taken me forever to set up custom blends.)
     
    Last edited: Jan 21, 2019
  8. CSmochinaArnia

    CSmochinaArnia

    Joined:
    Feb 26, 2018
    Posts:
    6
    I'm manipulating the path position by code and don't use a timeline track. The only problem is, when I'm setting the path position to 0, from whatever it was left at, instead of snapping to 0 position, it interpolates there. How can I force it to snap to 0, or whatever path position I want it to?
     
  9. CSmochinaArnia

    CSmochinaArnia

    Joined:
    Feb 26, 2018
    Posts:
    6
    Found a way to force it. Disable the brain while setting it and enabling in a frame later.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    Or, perhaps cleaner, you can set vcam.PreviousStateIsValid = false.
     
  11. CSmochinaArnia

    CSmochinaArnia

    Joined:
    Feb 26, 2018
    Posts:
    6
    That is awesomest! Thank you
     
  12. Split3

    Split3

    Joined:
    Aug 21, 2017
    Posts:
    4
    Hey, I'm working with dolly track, can I make from 1 rail path, 2 path choices?
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    Paths cannot branch.
    If you want to branch, you need to make a second path and switch to it.
     
  14. Split3

    Split3

    Joined:
    Aug 21, 2017
    Posts:
    4
    How could I switch them by my player pos? Any ideas?
     
  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    Maybe have a trigger collider somewhere. When player enters it, trigger calls your code to do the switch
     
  16. Laniemme

    Laniemme

    Joined:
    Jun 11, 2016
    Posts:
    40
    I created a 'dolly track and cart' where I need the vcam to face in the direction of the track shown in grey (think of a train driver holding a video camera). Due to this behavior, there is no 1 target to look at or follow. By default the camera is just facing the original direction it is set at for the whole duration of the track. I'm sure this is probably something simple, but I haven't found it yet.
     

    Attached Files:

  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    upload_2019-4-23_12-30-0.png
     
    Laniemme likes this.
  18. Laniemme

    Laniemme

    Joined:
    Jun 11, 2016
    Posts:
    40
    Thank you!
     
    Gregoryl likes this.
  19. ZAXIS

    ZAXIS

    Joined:
    Sep 30, 2016
    Posts:
    16
    Let's assume I have a net of different paths:
    upload_2019-8-19_12-52-1.png

    Would you advice anything smarter than checking every frame proximity to each of these paths and switching when it gets over some treashold? This would not scale well
     
  20. aerospacevitd

    aerospacevitd

    Joined:
    Nov 29, 2017
    Posts:
    1
    Can you use the cinemachine path to animate non camera game objects? It seems to not move any object I've put under a virtual camera.
     
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    That's pretty much the way to do it. You'll have to figure out a way to optimize this, perhaps with space partitioning, so that you can tune how often you check for proximity.
     
  22. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    Yes. Don't put objects under the vcam. Use CInemachineDollyCart, which is a transform that can follow a path. Or roll your own, based on the code in CinemachineDollyCart.
     
  23. DirgaS

    DirgaS

    Joined:
    Jul 16, 2018
    Posts:
    1
    Hi,

    I just try using cinemachine recently and I want to make a track that following my rollercoaster track that have loop in the middle, but when I try to make the track following my track it become twisted. Is there a way to make the track doesn't get twisted like that? Thanks in advance.

    upload_2019-8-28_15-16-37.png

    upload_2019-8-28_15-19-4.png
     
  24. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    Adjust the waypoint roll

    upload_2019-8-28_8-39-21.png
     
  25. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    110
    Hi, this doesn't work for me to get the cam position along the tracked dolly, can't find how to get what path the vCam is on:

    vcam.GetCinemachineComponent<CinemachineTrackedDolly>().m_PathPosition

    Can't attach Dolly Track to CinemachineTrackedDolly as component. Interestingly I don't get any log null ref either in console.

    I tried also with CinemachineSmoothPath, CinemachinePath to no avail.

    I couldn't work out from the documentation how to get current path position, can you please suggest, thanks a bunch,

    On Unity 2019.1.6f1, cinemachine 2.3.4
     

    Attached Files:

  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,844
    You need one object which is the CinemachinePath (or SmoothPath). You have that.
    Next, you need another object which is a vcam with a CinemachineTrackedDolly component (you have that too).

    Then you connect them by adding a reference to your path in the CinemachineTrackedDolly component:
    Code (CSharp):
    1. vcam.GetCinemachineComponent<CinemachineTrackedDolly>().m_Path = myPath;
    You get the path position like this:
    Code (CSharp):
    1. float pathPosition = vcam.GetCinemachineComponent<CinemachineTrackedDolly>().m_PathPosition;
     
  27. LezTusi

    LezTusi

    Joined:
    Nov 15, 2014
    Posts:
    28
    Hello, I need to change the dolly cam's Camera Up - Path Direction to Look at the left/right path direction instead of the default/current one that is on the forward path direction. I don't want to use the Composer to avoid unnecessary rotations. it's for a 2.5d game I'm making. is that possible? upload_2019-9-5_10-41-25.png

    [UPDATE] I think i got it, but I'm not sure if i'm calculating it right, but so far it works for my needs.

    Code (CSharp):
    1.         public Vector3 RotationOffset;
    2.  
    3.         protected override void PostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
    4.         {
    5.             if (stage == CinemachineCore.Stage.Body)
    6.             {
    7.                 state.RawOrientation *= Quaternion.Euler(RotationOffset);
    8.             }
    9.         }
     
    Last edited: Sep 5, 2019