01-18-2016, 02:47 AM
(This post was last modified: 01-21-2016, 05:36 PM by Trainzland.)
I want to use the API command Move() and get a callback through the Event-System.
This is useful to get a function call in side the current script while Move() reaches a ControlPoint.
If any SplineController runs over the Spline.ControllPoint then nControlPointReachedEvent() is triggered well.
You can determine the SC in e.Sender for sure (see Default Curvy Events Handler.cs)
But unfortunately I get no fire while Move() runs over a CP.
Perhaps I use Move(tf, dir, fdist, clamp) in a wrong way?
This is useful to get a function call in side the current script while Move() reaches a ControlPoint.
If any SplineController runs over the Spline.ControllPoint then nControlPointReachedEvent() is triggered well.
You can determine the SC in e.Sender for sure (see Default Curvy Events Handler.cs)
But unfortunately I get no fire while Move() runs over a CP.
Perhaps I use Move(tf, dir, fdist, clamp) in a wrong way?
Code:
public class PassiveFollower : MonoBehaviour {
public CurvySpline Spline;
public float aDist;
public float tf = 0;
public int dir = 1;
public Vector3 posfollow;
IEnumerator Start() {
// Wait until the spline is initialized
if (Spline) {
while (!Spline.IsInitialized)
yield return null;
}
// Add EventTrigger to the current Spline
Spline.OnMoveControlPointReached.AddListenerOnce(onControlPointReachedEvent);
}
void Update() {
aDist += 0.01f;
tf = Spline.DistanceToTF(aDist);
posfollow = Spline.Move(ref tf, ref dir, 0.01, CurvyClamping.Clamp) + Spline.transform.position;
transform.position = posfollow;
}
void onControlPointReachedEvent(CurvySplineMoveEventArgs e) {
//Gets triggered by a SplineCOntroller but not by Move();
Debug.Log("onControlPointReachedEvent");
}
}
(Henry Ford) Each hour more of searching is each hour less of your live time.