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
  Removing the objects behind an object alms94 6 6 12-06-2023, 09:31 PM
Last Post: _Aka_
  Add ControlPoint "ahead" of spline end jh092 3 5 10-23-2023, 08:48 PM
Last Post: _Aka_
  Getting object on spline Position when Spline has coordinates larger than 2000 velikizlivuk 5 10 09-05-2023, 01:01 PM
Last Post: velikizlivuk
  Moving object down or up the spline using gravity velikizlivuk 6 16 07-26-2023, 10:06 PM
Last Post: _Aka_

Forum Jump: