Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help Stopping an Object at a ControlPoint
#1
Exclamation 
I am working on a ring menu for our game using Curvy. We are using OnControlPointReached to determine when a control  point is - well - reached. However, it appears to be wildly inaccurate, and does not stop at the exact point. We have attempted to also force the position once the point is reached, however it does not appear to work correctly.

In the following GIF, you can see the issue occurring as we move forwards and backwards in the menu.

GIF Of Issue Occuring

The code we are using to move the object looks like this:
Code:
  splineControl.MovementDirection = MovementDirection.Forward;
           splineControl.MoveMode = CurvyController.MoveModeEnum.Relative;
           splineControl.Speed = 1f;
           splineControl.Play();

The following code is then used to listen for OnControlPointReached, and attempt to force the position:
Code:
void ControlPointReached(CurvySplineMoveEventArgs inArgs)
        {
            if ((inArgs.Sender != splineControl) || (inArgs.Sender == splineControl && inArgs.ControlPoint == LastSplineSegment))
                return;

            LastSplineSegment = inArgs.ControlPoint;

            // Make absolutely sure the Sender is at the desired position. Sometimes they'll jump otherwise.
            splineControl.Pause();
            splineControl.Position = inArgs.ControlPoint.TF;
            splineControl.Refresh();

            Debug.Log(splineControl.Position + " / " + inArgs.ControlPoint.TF);

            NodeIsMoving = false;
        }

The event listener is absolutely getting triggered. The values in the debug output above showing the splineControl.Position and inArgs.ControlPoint.TF match perfectly. HOWEVER - if we go to the Position section of the Spline Controller component on the object in question, the Position is NOT the same as what was dumped to the console. If we manually type in the value to the Position section, then it jumps to the correct position.

I am pretty stuck on this and could really use any help I can get. Thank you in advance!
Reply
#2
Hi,

Here is the code you need:
Code:
   public void ControlPointReached(CurvySplineMoveEventArgs inArgs)
   {
       if (shouldStop)
       {
           inArgs.Sender.Pause();
           inArgs.Cancel = true;
       }
   }

The Pause call makes the controller pause starting from the next frame. It does not stop the movement currently processed this frame. To stop that movement, setting the Cancel property of the event to true is the key.

Please let me know if you need anything else

Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
That solved it perfectly - thank you!

(08-01-2019, 12:50 PM)_Aka_ Wrote: Hi,

Here is the code you need:
Code:
   public void ControlPointReached(CurvySplineMoveEventArgs inArgs)
   {
       if (shouldStop)
       {
           inArgs.Sender.Pause();
           inArgs.Cancel = true;
       }
   }

The Pause call makes the controller pause starting from the next frame. It does not stop the movement currently processed this frame. To stop that movement, setting the Cancel property of the event to true is the key.

Please let me know if you need anything else

Have a nice day
Reply
#4
You are welcome
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Best practice for mass-object instancing along 100km spline (railways) plus streaming bs@vectorvision.de 10 493 09-24-2019, 03:42 PM
Last Post: _Aka_
  Generating multiple object on changing transform jawadkhan.9026 12 1,118 09-06-2019, 09:39 PM
Last Post: _Aka_
  Orient Spline to Object DanMarionette 1 378 06-11-2019, 05:56 PM
Last Post: _Aka_
  Spawning object with correct rotation at spline end arrnav96 2 541 05-21-2019, 02:19 PM
Last Post: arrnav96

Forum Jump: