Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Got Position { Nan } error.
#3
(08-14-2020, 02:17 PM)_Aka_ Wrote: Hi,
Your video is private.
The error happens when the controller updates itself. So my questions are:
1- on what spline that controller is running? Is it the same spline that gets destroyed (dynamicPath)
2- do you confirm that this error happens after you dispose TempPath?
If so, consider destroying the controller at the same time as the spline it runs on. Or if not possible, stop the controller, or set its spline to null or any other spline still alive

after two day dig down, finally found the reason.
well an issue was I did something like this.

Code:
SwitchTo(m_TempPath.dynamicPath, 0f, 0f);
since I found switch to are only lerp to target position & rotation, I design to dynamic generate via CurvySpline.Create,
and I did some lazy change to achieve that, I mean "input the ZERO duration."
because of that, following line had divide zero issue.

in SplineController.cs > ComputeTargetPositionAndRotation()
Code:
targetPosition = OptimizedOperators.LerpUnclamped(switchlessPosition, positionOnSwitchToSpline, SwitchProgress);
the problem hidden in getter "SwitchProgress" > "SwitchDuration" that one will be zero.

well, the solution for me was avoid using SwitchTo(), but do as follow when switch_duration == 0.
Code:
base.Stop();
Spline = m_TempPath.dynamicPath;
RelativePosition = float.Epsilon;
Play();

well seem not a complete solution, but it will do.

a little suggestion for author,
perhaps adding a early return cases in "SplineController.cs > ComputeTargetPositionAndRotation()",
e.g.
Code:
if (SwitchDuration <= 0f)
targetPosition = positionOnSwitchToSpline;
else
targetPosition = OptimizedOperators.LerpUnclamped(switchlessPosition, positionOnSwitchToSpline, SwitchProgress);

and I believe you will found the better solution like prevent the Zero duration SwitchTo request on high level.
anyway your call~ thanks for the assist.
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: