Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Got Position { Nan } error.
#1
Bug 
I was implement the dynamic generate path feature in my game.
however something was wrong.
seem like the coordinate calculation in "ComputeTargetPositionAndRotation" had an issue.

so the yellow line (bezier curve) in video was generate via "CurvySpline.Create()";
and calling "CurvySpline.Destroy()" to destroy itself.

when I try to use the generated path in runtime,
however nothing related to CurvySpline.Destroy().
Destroy right after travel didn't work, I need to delay 1 sec (yeah~ so dirty)
and then I tried even didn't Destroy that CurvySpline, at some point these error still popup ????


here is the video log.


here is the error message.
btw, rotation also wrong it's Vector3.zero.

transform.position assign attempt for 'SpaceShip_Small(Clone) #0003' is not valid. Input position is { NaN, NaN, NaN }.
UnityEngine.TransformConfusedet_position(Vector3)
FluffyUnderware.Curvy.Controllers.CurvyController:InitializedApplyDeltaTime(Single) (at Assets/Plugins/Curvy/Controllers/CurvyController.cs:710)
FluffyUnderware.Curvy.Controllers.SplineController:InitializedApplyDeltaTime(Single) (at Assets/Plugins/Curvy/Controllers/SplineController.cs:531)
FluffyUnderware.Curvy.Controllers.CurvyController:ApplyDeltaTime(Single) (at Assets/Plugins/Curvy/Controllers/CurvyController.cs:1014)
FluffyUnderware.Curvy.Controllers.CurvyController:Update() (at Assets/Plugins/Curvy/Controllers/CurvyController.cs:605)


not sure if it help, and here is the class I used to generate and destroy CurvySpline.
Code:
protected class TempPath : System.IDisposable
{
public CurvySplineSegment start => dynamicPath.FirstVisibleControlPoint;
public CurvySplineSegment end => dynamicPath.LastVisibleControlPoint;
public float pathLength => dynamicPath.Length;
public float targetTf;

public CurvySpline dynamicPath;
public CurvySpline targetPath;
private bool disposedValue;

public TempPath(CurvySpline _dynamicPath, CurvySpline _target, float _targetFt)
{
dynamicPath = _dynamicPath;
targetPath = _target;
targetTf = _targetFt;
}
~TempPath()
{
Dispose(disposing: false);
}

/// <summary>Generate temp path</summary>
/// <param name="agent">the agent transfrom for calculate start tangent.</param>
/// <param name="to">target curve wanted to move on.</param>
/// <param name="toFt">-1f : auto search closest</param>
/// <returns></returns>
public static TempPath GeneratePathTo(CurvyController agent,
CurvySpline to, float toFt = -1f)
{
if (to == null)
throw new System.NullReferenceException();

// Generate path !
CurvySpline curve = CurvySpline.Create();
curve.Interpolation = CurvyInterpolation.Bezier;
curve.Orientation = CurvyOrientation.Static;
curve.AutoEndTangents = true;
curve.Closed = false;
curve.GizmoColor = Color.yellow;
curve.ShowGizmos = true;
curve.CacheDensity = 30;

// point on travel path.
Vector3 startPoint = agent.transform.position;
Vector3 startTangent = agent.transform.forward;

CurvySplineSegment start = curve.Add(startPoint, Space.World);
start.AutoHandles = false;
start.HandleOutPosition = startTangent;
start.HandleIn = -start.HandleOut;

// point to switch path.
float endTF = toFt >= 0f ?
toFt : // will clamp in plugin
to.GetNearestPointTF(startTangent, Space.World);

to.InterpolateAndGetTangentFast(endTF, out Vector3 endPoint, out Vector3 endTangent, Space.World);
CurvySplineSegment end = curve.Add(endPoint, Space.World);
end.AutoHandles = false;
end.HandleInPosition = endTangent;
end.HandleOut = -end.HandleIn;
return new TempPath(curve, to, endTF);
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
dynamicPath?.Destroy();
}

dynamicPath = null;
disposedValue = true;
}
}

public void Dispose()
{
Dispose(disposing: true);
System.GC.SuppressFinalize(this);
}
}
Reply


Messages In This Thread
Got Position { Nan } error. - by Canis - 08-14-2020, 11:37 AM
RE: Got Position { Nan } error. - by _Aka_ - 08-14-2020, 02:17 PM
RE: Got Position { Nan } error. - by Canis - 08-19-2020, 05:16 AM
RE: Got Position { Nan } error. - by _Aka_ - 08-20-2020, 06:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
  How could I get position in spline from "From" value in BuildRasterizedPath? Chanon 1 8 02-12-2024, 09:54 PM
Last Post: _Aka_
  Finding relative position across connected splines DekoGames 1 8 02-05-2024, 10:11 PM
Last Post: _Aka_

Forum Jump: