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
Exclamation Runtime error when using Curvy Generator with Game Object Deform studentloan 3 13 04-22-2022, 09:00 PM
Last Post: _Aka_
  Spline object follow another Object Doomchecker 2 10 02-02-2022, 04:59 PM
Last Post: Doomchecker
  best way to rotate, change offset, and inset position of splinecontroller object smackledorf 1 19 01-17-2022, 01:39 PM
Last Post: _Aka_
Wink Moving object along spline close to player minaa 7 23 12-27-2021, 02:39 PM
Last Post: _Aka_

Forum Jump: