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
Photo Position in Input Spots not working on all directions. Mike Danielsson 2 9 09-03-2022, 02:22 PM
Last Post: Mike Danielsson
  TF to world position niuage 2 8 03-06-2022, 08:16 AM
Last Post: niuage
Wink In SplineController OnPositionReachedList Event is missing shimizu 2 11 02-07-2022, 12:47 PM
Last Post: shimizu
  best way to rotate, change offset, and inset position of splinecontroller object smackledorf 1 19 01-17-2022, 01:39 PM
Last Post: _Aka_

Forum Jump: