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

Question Spline Dolly

Discussion in 'Cinemachine' started by osgseb, May 25, 2023.

  1. osgseb

    osgseb

    Joined:
    Jan 17, 2022
    Posts:
    26
    Hello folks,

    I'm testing Cinemachine 3 and more specifically the Spline Dolly. I tried to make something simple, in my case a spline containing 3 points which form a L shape. Second and third points have a Y rotation but it seems that rotation is never applied to the camera. Is that normal ? Is there a way to make orientation applied the same way position is applied ?

    Thanks
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    What happens when you set the Camera Up to Spline?

    upload_2023-5-25_12-52-49.png
     
  3. osgseb

    osgseb

    Joined:
    Jan 17, 2022
    Posts:
    26
    The camera orientation changed directly and never changed again but no according to the orientation set in the spline points. If I look at the cinemachine camera script you can set the "position" behaviour to "spline" in the dropdown menu but you don't have the same option for orientation (I don't have Unity opened so not sure of parameter menu/value names)
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Maybe I don't understand your question. For me, when the Camera Up is set to Spline, the camera rotation is affected (even though it's a position behaviour):

    spline pos.gif

    Note that the camera orientation comes from the spline tangent, not from the rotation of the spline points.
     
  5. osgseb

    osgseb

    Joined:
    Jan 17, 2022
    Posts:
    26
    I think that's the explanation. I wanted the camera orientation to be set using the spline points because it would allow me to have more control by having a specific path + a specific camera orientation on that path.

    I guess I will have to add that behavior using a script. That's ok.

    Thank you
     
  6. osgseb

    osgseb

    Joined:
    Jan 17, 2022
    Posts:
    26
    Hello @Gregoryl

    I'm still investigating Cinemachine + Dolly Spline and wanted to experiment what seems a basic scenario. I have a character that can move freely inside a L shape corridor, I want the camera to be able to follow the target as it moves. I want the camera to be constraint by a L shape Spline and always looking in front and never rotate. If I do not check "Automatic Dolly" the camera won't move even if "Position Control" is set to "Spline Dolly". If I check "Automatic Dolly" the "Camera position" will automatically animate until it reaches the end, so it wont "follow" the target but try to "look at" the target depending of the "Rotation Control" value.

    Is there a way to have the camera following the character and automatically have it moving along the spline trying to "figure" the best position ?

    Thans
     

    Attached Files:

  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Yes there is. You can enable Automatic Dolly and set the method to Nearest Point To Target. That will automatically position the camera at the point on the spline that is closest to the tracking target's position.

    upload_2023-6-6_8-7-0.png

    However, looking at your path, it will probably not give you what you want, because in the corridor where the spline is, the camera will be very close to the target. You could add a position offset to the AutoDolly, but then it will be wrong on the other section of the path.

    You could write a custom AutoDolly method (a class that implements the SplineAutoDolly.ISplineAutoDolly interface - see the RunningRace sample for an example of this) to set the spline position the way you like, but this might be overkill in this case. Another alternative is to write a companion behaviour that sets the SplineDolly's path position. The SplineUtility class has methods to find nearest point and such.

    Maybe the best thing to do here is to step back and ask the question: why are you using a spline at all? Why not instead use a Position Composer in the Body with a small depth dead zone (matching the corridor's width)? Set the camera's rotation to be facing the way you want it, position composer will not change it.

    upload_2023-6-6_8-20-24.png
     
  8. osgseb

    osgseb

    Joined:
    Jan 17, 2022
    Posts:
    26
    I think you're right and this is exactly what I'm experimenting right now.
     
    Gregoryl likes this.