Search Unity

Taking fixed distance steps down dolly path

Discussion in 'Cinemachine' started by Percy-Pea, Jul 31, 2017.

  1. Percy-Pea

    Percy-Pea

    Joined:
    Aug 31, 2014
    Posts:
    75
    Hi all, I'm working on a VR project and interested in using the dolly path of Cinemachine to move the player down a set route.

    The issue with doing this in VR is movement can cause nausea, so we want to move at a set distance per frame/tick/second.

    Simply adjusting the position (m_PathPosition), or calling EvaulatePosition(x) from CinemachinePath.cs to return a vector, don't give the desired results as the vector returned is affected on how much the spline/path is curved.

    Thanks,

    David
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes, the paths are cubic curves and the relationship between path position and arc length is a complex one. Out-of-the-box, Cinemachine does not provide a method for locating a point on the path at a specific arc-distance along the path.

    You have a couple of options here:
    1. Replace the CinemachinePath implementation with another one that is more appropriate for your needs. This is fairly straightforward: CM demands only that your implementation inherit from CinemachinePathBase. Use your new path in the TrackedDolly.
    2. Add a method to the existing path implementation to return the path position of a point at a specific distance along the path. Look at CinemachinePathBase for the implementation of FindClosestPoint(). That might serve as a model for your new method. This will likely be computationally expensive, especially if you want high accuracy. You can probably speed this up by pre-computing an LUT.
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711