private void Awake() { if (ConstantSpeedTraversal) { // This must be called before calling any of the parametrization // evaluation methods! _splineLength = Spline.ParametrizeByArcLength(ParametrizationCount); _visualPoints = new PositionTangent[ParametrizationCount]; for (int i = 0; i < _visualPoints.Length; ++i) { _visualPoints[i] = Spline.EvalPositionTangentParametrized((float)i / (_visualPoints.Length - 1) * _splineLength); _visualPoints[i].Position = Spline.transform.TransformPoint(_visualPoints[i].Position); } } else { _visualPoints = new PositionTangent[ParametrizationCount]; for (int i = 0; i < _visualPoints.Length; ++i) { _visualPoints[i] = Spline.EvalPositionTangent((float)i / (_visualPoints.Length - 1)); _visualPoints[i].Position = Spline.transform.TransformPoint(_visualPoints[i].Position); } } }
public void InitScene() { curLevel = CreatLevelLand("level_land_0" + curLevelIndex, new Vector3(0, 0, 0)); curSpline = curLevel.transform.Find("Wayfinding").GetComponent <CatmullRomSpline3>(); var _splineLength = curSpline.ParametrizeByArcLength(100); maxDistance = curSpline.CalcTotalLength(); }