Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SplineController Reset to initial Position
#1
I am using the Spline Controller to move an object along a single spline.

Sometimes I need to "reset" the object to the start of the spline. How do I do that?

I tried calling 
mysplineController.Stop();
mysplineController.Play(); 

but that didn't seem to work so then I did

mysplineController.ResetOnStop = true;
mysplineController.Stop();
mysplineController.Play();

But that causes an exception below.

I also tried mysplineController.Warp(0); 

What is the best way to reset the object to the start of the spline?



Thanks
Jim



IndexOutOfRangeException: Array index is out of range.
FluffyUnderware.Curvy.CurvySplineSegment.DistanceToLocalF (Single localDistance) (at Assets/Packages/Curvy/Base/CurvySplineSegment.cs:2040)
FluffyUnderware.Curvy.CurvySpline.DistanceToTF (Single distance, CurvyClamping clamping) (at Assets/Packages/Curvy/Base/CurvySpline.cs:1100)
FluffyUnderware.Curvy.CurvySplineBase.DistanceToTF (Single distance) (at Assets/Packages/Curvy/Base/CurvySplineBase.cs:411)
FluffyUnderware.Curvy.CurvySplineBase.MoveByLengthFast (System.Single& tf, System.Int32& direction, Single distance, CurvyClamping clamping) (at Assets/Packages/Curvy/Base/CurvySplineBase.cs:724)
FluffyUnderware.Curvy.CurvySpline.MoveByLengthFast (System.Single& tf, System.Int32& direction, Single distance, CurvyClamping clamping) (at Assets/Packages/Curvy/Base/CurvySpline.cs:1184)
FluffyUnderware.Curvy.Controllers.SplineController.Advance (System.Single& tf, System.Int32& direction, MoveModeEnum mode, Single absSpeed, CurvyClamping clamping) (at Assets/Packages/Curvy/Controllers/SplineController.cs:443)
FluffyUnderware.Curvy.CurvyController.Refresh () (at Assets/Packages/Curvy/Base/CurvyController.cs:842)
FluffyUnderware.Curvy.Controllers.SplineController.Refresh () (at Assets/Packages/Curvy/Controllers/SplineController.cs:258)
FluffyUnderware.Curvy.CurvyController.Update () (at Assets/Packages/Curvy/Base/CurvyController.cs:609)
Reply
#2
Either use 

mySplineController.Reset()  

or 

mySplineController.Position=mySplineController.InitialPosition

Both should work. I'm looking into the exception, that shouldn't happen. Anyways, ResetOnStop only has an effect if you use the Animate feature.
Reply
#3
Thanks for the fast response 

mySplineController.Reset()   is protected.

Something to note is I am dynamically changing the location of the ControlPoints of the Spline used by the SplineController. So its possible that is part of the cause of the index out of bounds, I suspect the spline is getting shorter and that isnt handled by that code.

Is there something that should be called when the spline is changed?



(06-14-2016, 02:13 PM)Jake Wrote: Either use 

mySplineController.Reset()  

or 

mySplineController.Position=mySplineController.InitialPosition

Both should work. I'm looking into the exception, that shouldn't happen. Anyways, ResetOnStop only has an effect if you use the Animate feature.
Reply
#4
(06-14-2016, 02:59 PM)aspartamed Wrote: Is there something that should be called when the spline is changed?
Yeah, call CurvySpline.Refresh() to immediately use the changes, otherwise Refresh() will be called internally next frame. In general, calling Refresh() often isn't bad - it won't do anything unless spline parts are flagged dirty or you force refresh by Refresh(true).
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Got Position { Nan } error. Canis 3 666 08-20-2020, 06:27 PM
Last Post: _Aka_
  SplineController slows down approaching connections jh092 5 895 08-07-2020, 03:56 PM
Last Post: _Aka_
  Converting spline collider hit point to spline position jh092 7 1,428 06-26-2020, 09:48 PM
Last Post: _Aka_
  Extrusion does not match Controller position JasperBPT 3 993 05-26-2020, 10:18 PM
Last Post: _Aka_

Forum Jump: