11-07-2017, 12:07 AM
Hey,
So I'm making a system where I'm going to use a control point before a connection to initiate some sort of routine that asks if I want to split left/right. Then once I'm at the last CP, there's a connection there for left or right splines to carry on.
Problem on is I find almost no help in the documentation or videos about this, so I'm essentially reverse engineering the examples. Oh well, better than nothing I guess.
Here's the code I'm using so far,mostly borrowed from 12-Train:
Pretty simple, doesn't really do anything yet. Thing is, for the last chunk it stops everything, and tells me there's a Null Reference Exception:
My line of thought is that if I can detect if I'm currently in a Connection node, then I can tell Curvy to go Left/Right based on the players choice. How do i detect this?
Perhaps there's an even simpler way to go about what I want to achieve?
So I'm making a system where I'm going to use a control point before a connection to initiate some sort of routine that asks if I want to split left/right. Then once I'm at the last CP, there's a connection there for left or right splines to carry on.
Problem on is I find almost no help in the documentation or videos about this, so I'm essentially reverse engineering the examples. Oh well, better than nothing I guess.
Here's the code I'm using so far,mostly borrowed from 12-Train:
Code:
public void OnCPReached (CurvySplineMoveEventArgs e)
{
Debug.Log("CP!");
var mData = e.ControlPoint.GetMetadata<metaTest>();
if (mData)
{
Debug.Log("MD!");
mData.doubleInt();
cpCount = mData.testInt;
}
var connection = e.ControlPoint.Connection.OtherControlPoints(e.ControlPoint)[0];
if (connection)
{
Debug.Log("Connection!");
//Debug.Log(e.ControlPoint.Connection.OtherControlPoints(e.ControlPoint)[0]);
//e.Follow(e.ControlPoint.Connection.OtherControlPoints(e.ControlPoint)[0]);
//SplineController controller = (SplineController)e.Sender;
//controller.Spline = e.Spline;
//controller.RelativePosition = e.TF;
}
}
Pretty simple, doesn't really do anything yet. Thing is, for the last chunk it stops everything, and tells me there's a Null Reference Exception:
Code:
NullReferenceException: Object reference not set to an instance of an object
Player.OnCPReached (FluffyUnderware.Curvy.CurvySplineMoveEventArgs e) (at Assets/Player.cs:215)
UnityEngine.Events.InvokableCall`1[FluffyUnderware.Curvy.CurvySplineMoveEventArgs].Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:189)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:637)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:773)
UnityEngine.Events.UnityEvent`1[T0].Invoke (.T0 arg0) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_1.cs:53)
FluffyUnderware.Curvy.Controllers.SplineController.onControlPointReachedEvent (FluffyUnderware.Curvy.CurvySplineMoveEventArgs e) (at Assets/Packages/Curvy/Controllers/SplineController.cs:665)
UnityEngine.Events.InvokableCall`1[FluffyUnderware.Curvy.CurvySplineMoveEventArgs].Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:189)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:637)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:773)
UnityEngine.Events.UnityEvent`1[T0].Invoke (.T0 arg0) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_1.cs:53)
FluffyUnderware.Curvy.CurvySplineBase.OnMoveControlPointReachedEvent (FluffyUnderware.Curvy.CurvySplineMoveEventArgs e) (at Assets/Packages/Curvy/Base/CurvySplineBase.cs:188)
FluffyUnderware.Curvy.CurvySpline.eventAwareMoveDistance (System.Single& tf, System.Int32& direction, Single distance, CurvyClamping clamping, Boolean fastMode) (at Assets/Packages/Curvy/Base/CurvySpline.cs:2744)
FluffyUnderware.Curvy.CurvySpline.MoveByLengthFast (System.Single& tf, System.Int32& direction, Single distance, CurvyClamping clamping) (at Assets/Packages/Curvy/Base/CurvySpline.cs:1193)
FluffyUnderware.Curvy.Controllers.SplineController.Advance (System.Single& tf, System.Int32& direction, MoveModeEnum mode, Single absSpeed, CurvyClamping clamping) (at Assets/Packages/Curvy/Controllers/SplineController.cs:497)
FluffyUnderware.Curvy.CurvyController.Refresh () (at Assets/Packages/Curvy/Base/CurvyController.cs:880)
FluffyUnderware.Curvy.Controllers.SplineController.Refresh () (at Assets/Packages/Curvy/Controllers/SplineController.cs:310)
FluffyUnderware.Curvy.CurvyController.Update () (at Assets/Packages/Curvy/Base/CurvyController.cs:632)
My line of thought is that if I can detect if I'm currently in a Connection node, then I can tell Curvy to go Left/Right based on the players choice. How do i detect this?
Perhaps there's an even simpler way to go about what I want to achieve?