Here are the examples of the csharp api FollowCurveTarget.CatmullRom(UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, float, float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
View Source File : FollowCurveTarget.cs
License : The Unlicense
Project Creator : Unity-Technologies
License : The Unlicense
Project Creator : Unity-Technologies
void FixedUpdate ()
{
if (CurveDuration < Mathf.Epsilon)
return;
var curvePointCount = CurvePoints.Length;
if (curvePointCount < 2)
{
m_CurveTime = 0.0f;
m_Joint.target = transform.position;
return;
}
m_CurveTime += Time.deltaTime;
while (m_CurveTime > CurveDuration)
m_CurveTime -= CurveDuration;
var start = (int)((curvePointCount / CurveDuration) * m_CurveTime);
var end = start < (curvePointCount-1) ? start+1 : 0;
var previous = start > 0 ? start-1 : curvePointCount-1;
var next = end < (curvePointCount-1) ? end+1 : 0;
var unitDuration = CurveDuration / curvePointCount;
var unitElapsedTime = m_CurveTime - (start * unitDuration);
var samplePoint = CatmullRom (CurvePoints[previous], CurvePoints[start], CurvePoints[end], CurvePoints[next], unitElapsedTime, unitDuration);
m_Joint.target = samplePoint;
}