Search Unity

Creating a linear CinemachinePath?

Discussion in 'Cinemachine' started by FeastSC2, Jun 14, 2019.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    How can I create a linear Cinemachine Path?

    I thought I could remove the complexities of the path by setting the resolution to 1, which in the editor view shows that there is no curve between 2 waypoints but it's just a visual indicator: it does not impact the Path.EvaluatePositionAtUnit() function. So my path ends up being curved in playmode.

    What can I do to have a straight line between each waypoint when I call the CinemachineBasePath.Path.EvaluatePositionAtUnit() ?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Replace the CinemachineSmoothPath behaviour with a CinemachinePath behaviour and set the tangents to 0.

    upload_2019-6-14_9-14-10.png
     
  3. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Thanks for answering!
    I did this, but I realized that I have a non-constant speed along the path (I slow down near waypoints) but that's not just it: I sometimes speed up along the way in a more random fashion.

    I am using the DollyCart component to follow the path, so it's not anything I built myself. And I still have non-constant speeds. Here's the path below.

    upload_2019-6-14_15-17-7.png
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Make sure you set the units to Distance, or the velocities will be weird.

    upload_2019-6-14_9-22-30.png
     
  5. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Well this is stupid, I just realized I had a small Tangent values on some of the points, by looking again at the screenshot above. Somehow small values always find their way in the tangent Vector3!

    I'm sorry for wasting your time. It works as intended. I might do a component that goes over the waypoints' roll and tangents and set them to 0 so that this doesn't happen again.
     

    Attached Files:

  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    I hadn't noticed those in your screenshot either.
    What do you mean that the small values creep in? By themselves??? If so that's not good and should be looked at.
     
  7. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    The problem is that the handles are overlapped very often, my waypoint handles and the tangent handles. I generally do not know which is which and I would prefer to be able to turn the tangent handles off entirely.
    Another option would be to force the path to be linear.

    Here's an example where I'm not trying to grab the tangent handles but I do it regardless:
    https://gifyu.com/image/EMUk
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    It's because of this:

    upload_2019-6-14_9-40-2.png

    Turn it off
     
  9. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    This turns back on as soon as I enter playmode. I wasn't sure it was a bug though.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Sounds like a bug to me. Just keep turning it off. It's there precisely to address the ambiguity when handles overlap.
     
  11. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Happy bug hunting then :) Looks like something minor.
     
  12. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I don't seem to have a linear speed in one case here despite having no tangential values.

    You can see the cylinder slows down when it arrives to each waypoint. The movement looks like a quad ease in ease out. Watch the gif posted below:

    https://gifyu.com/image/EMUi

    PS: I also turned of the collider of the cylinder and that's not the reason for slow down.

    upload_2019-6-14_15-54-28.png

    upload_2019-6-14_15-54-9.png
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Hmmm... you're right.
    Set the path resolution to maximum. That should work around the problem.
     
    FeastSC2 likes this.
  14. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I'm not sure if this is a desired behaviour but when I create a new point for my path by clicking the + sign in the path details dropdown, the values for the tangent are generally not 0. In my case, it has small values, like -1, or other values smaller than that. Just giving you a heads up.
     
  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Yeah, it kind of sucks. Workflow is not optimized for linear paths, which is a minority use-case.
    Thanks for the heads-up :)
     
    FeastSC2 likes this.
  16. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Hey Gregoryl, I just downloaded the latest Cinemachine update. Could it be you forgot about this issue? The bugs are still present for me.
     
  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Yup, that ship had already sailed. There will be another one :)
     
  18. biscito

    biscito

    Joined:
    Apr 3, 2013
    Posts:
    138
    hi, is it possible to create a mesh that follow cinemachinepath ?

    thx
     
  19. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Can you elaborate? I don't quite understand what you're looking for