Hi, I am using Cinemachine 2.6.0 in Unity 2019.2.9
as I wrote in the title, I noticed this behavior : whether I pass PositionUnits.Normalized or PositionUnits.PathUnits as 2nd argument, the method returns the same output. Maybe I am not fully grasping how StandardizeUnit works, or maybe my logic is faulty so I come here to check if anyone has tried that.
My use case is that I would like to process a distance differently for moving my object along a Cinemachine Smooth Path.
Script is inspired by the CinemachineDollyCart script, with some modifications.
I use normalized position so that increments are linear and speed is constant (in other cases I would have speed variation depending on the distance between waypoints).
And I use waypoint-relative position (PathUnits) to evaluate the current desired speed along the path (indeed it’s a tool for the author of the path to be able to input varying speed along the path in the editor by specifying steps/waypoints speed changes.
My problem is that, however I tried to implement it, I cannot have both.
```csharp
*public CinemachinePathBase m_Path;
public float m_Speed;
public bool m_isReversed = false;
public float m_PositionAgnostic;
public float m_PositionNormalized;
public float m_PositionWaypointRelative;
void Update()
{
if (m_Path != null) {
float speed = Application.isPlaying ? m_Speed : 0;
m_PositionAgnostic += speed * Time.deltaTime;
SetCartPosition(m_PositionAgnostic);
}
}
void SetCartPosition(float distanceAlongPath)
{
if (m_Path != null)
{
//Position
m_PositionNormalized = m_Path.StandardizeUnit(distanceAlongPath, CinemachinePathBase.PositionUnits.Normalized);
m_PositionWaypointRelative = m_Path.StandardizeUnit(distanceAlongPath, CinemachinePathBase.PositionUnits.PathUnits);
//Movement is normalized for speed to be constant
float pos = m_PositionNormalized;
if (m_isReversed) {
pos = 1f - m_PositionNormalized;
}
transform.position = m_Path.EvaluatePositionAtUnit(pos, CinemachinePathBase.PositionUnits.Normalized);
//Speed variations along path : these uses a position relative to the waypoints
if (m_Path.GetComponent<PathParameter>() != null && m_Path.GetComponent<PathParameter>().speedVariations.Count > 2)
m_Speed = EvaluateCartSpeed(m_PositionWaypointRelative) * m_speedHackExposant;
else
m_Speed = m_baseSpeed * m_speedHackExposant;
}
//These logs will output the same values
Debug.Log("m_PositionNormalized= " + m_PositionNormalized + " / m_PositionWaypointRelative= "+ m_PositionWaypointRelative);
}*
```