09-14-2021, 04:24 PM
If I have an object using a Spline Controller for movement, is there a way to remove the object from the spline's movement control temporarily or permanently? For example, suppose I've got a ship using a spline for movement but want to evade a shot by the player with some other movement algorithm. I've tried the following ways but have issues with each of them, I'm hoping I'm just missing something. I'm doing these when the controller raises the OnEndReached event for the spline.
NullReferenceException: Object reference not set to an instance of an object
FluffyUnderware.Curvy.Controllers.SplineController.MovementCompatibleGetPosition (FluffyUnderware.Curvy.Controllers.SplineController controller, FluffyUnderware.Curvy.CurvyPositionMode positionMode, FluffyUnderware.Curvy.CurvySplineSegment& controlPoint, System.Boolean& isOnControlPoint, System.Single clampedPosition) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:603)
FluffyUnderware.Curvy.Controllers.SplineController.InvokeEventHandler (FluffyUnderware.Curvy.Controllers.CurvySplineMoveEvent event, FluffyUnderware.Curvy.Controllers.CurvySplineMoveEventArgs eventArgument, FluffyUnderware.Curvy.CurvyPositionMode positionMode, FluffyUnderware.Curvy.CurvySplineSegment& postEventsControlPoint, System.Boolean& postEventsIsControllerOnControlPoint, System.Single& postEventsControlPointPosition) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:937)
FluffyUnderware.Curvy.Controllers.SplineController.HandleReachingNewControlPoint (FluffyUnderware.Curvy.CurvySplineSegment controlPoint, System.Single controlPointPosition, FluffyUnderware.Curvy.CurvyPositionMode positionMode, System.Single currentDelta, System.Boolean& cancelMovement, FluffyUnderware.Curvy.CurvySplineSegment& postEventsControlPoint, System.Boolean& postEventsIsControllerOnControlPoint, System.Single& postEventsControlPointPosition) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:921)
FluffyUnderware.Curvy.Controllers.SplineController.EventAwareMove (System.Single distance) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:786)
FluffyUnderware.Curvy.Controllers.SplineController.Advance (System.Single speed, System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:494)
FluffyUnderware.Curvy.Controllers.CurvyController.InitializedApplyDeltaTime (System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/CurvyController.cs:675)
FluffyUnderware.Curvy.Controllers.SplineController.InitializedApplyDeltaTime (System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:538)
FluffyUnderware.Curvy.Controllers.CurvyController.ApplyDeltaTime (System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/CurvyController.cs:1014)
FluffyUnderware.Curvy.Controllers.CurvyController.Update () (at Assets/Standard Assets/Curvy/Curvy/Controllers/CurvyController.cs:605)
Any thoughts would be appreciated. Thanks for your help.
- Stop the spline controller - when I try to change the transform position of the object, the spline controller still makes it stay on the path.
- Disable the spline controller in code - when I try to change the transform position of the object, the spline controller still makes it stay on the path. Maybe because I'm trying to do the movement in the same frame as when I disable the controller?
- Remove the current spline from the controller (i.e. controller.Spline = null) - This allows me to change the object's transform position, but it makes the controller angry and throws an error... I'm assuming this occurs because the spline is technically still in use. Details below:
NullReferenceException: Object reference not set to an instance of an object
FluffyUnderware.Curvy.Controllers.SplineController.MovementCompatibleGetPosition (FluffyUnderware.Curvy.Controllers.SplineController controller, FluffyUnderware.Curvy.CurvyPositionMode positionMode, FluffyUnderware.Curvy.CurvySplineSegment& controlPoint, System.Boolean& isOnControlPoint, System.Single clampedPosition) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:603)
FluffyUnderware.Curvy.Controllers.SplineController.InvokeEventHandler (FluffyUnderware.Curvy.Controllers.CurvySplineMoveEvent event, FluffyUnderware.Curvy.Controllers.CurvySplineMoveEventArgs eventArgument, FluffyUnderware.Curvy.CurvyPositionMode positionMode, FluffyUnderware.Curvy.CurvySplineSegment& postEventsControlPoint, System.Boolean& postEventsIsControllerOnControlPoint, System.Single& postEventsControlPointPosition) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:937)
FluffyUnderware.Curvy.Controllers.SplineController.HandleReachingNewControlPoint (FluffyUnderware.Curvy.CurvySplineSegment controlPoint, System.Single controlPointPosition, FluffyUnderware.Curvy.CurvyPositionMode positionMode, System.Single currentDelta, System.Boolean& cancelMovement, FluffyUnderware.Curvy.CurvySplineSegment& postEventsControlPoint, System.Boolean& postEventsIsControllerOnControlPoint, System.Single& postEventsControlPointPosition) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:921)
FluffyUnderware.Curvy.Controllers.SplineController.EventAwareMove (System.Single distance) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:786)
FluffyUnderware.Curvy.Controllers.SplineController.Advance (System.Single speed, System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:494)
FluffyUnderware.Curvy.Controllers.CurvyController.InitializedApplyDeltaTime (System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/CurvyController.cs:675)
FluffyUnderware.Curvy.Controllers.SplineController.InitializedApplyDeltaTime (System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/SplineController.cs:538)
FluffyUnderware.Curvy.Controllers.CurvyController.ApplyDeltaTime (System.Single deltaTime) (at Assets/Standard Assets/Curvy/Curvy/Controllers/CurvyController.cs:1014)
FluffyUnderware.Curvy.Controllers.CurvyController.Update () (at Assets/Standard Assets/Curvy/Curvy/Controllers/CurvyController.cs:605)
Any thoughts would be appreciated. Thanks for your help.