12-02-2015, 05:34 PM
Hi,
I am new to Curvy and need help in accessing one existing CurvySpline from a custom script.
So, I have created one CurvySpline name "XYZ". And then created one cube and attached the below script to this cube. When I run the scene, I expect the cube to move along the spline.
In the below script, I dragged the curvy gameObject into the public variable "spline". But I am getting the error "NullReferenceException: Object reference not set to an instance of an object
TesterScript+<Start>c__Iterator35.MoveNext () (at Assets/Scripts/TesterScript.cs:11)
However, In the editor if I just add the SplineController script to the cube, then it starts moving along the spline without any issues. So, not sure what am I doing wrong.
Can you please help me !!!
using UnityEngine;
using System.Collections;
using FluffyUnderware.DevTools;
public class TesterScript : FluffyUnderware.Curvy.Controllers.SplineController
{
public FluffyUnderware.Curvy.CurvySpline spline;
// Use this for initialization
IEnumerator Start()
{
while (!spline.IsInitialized)
yield return 0;
}
void Update () {
if (spline && spline.IsInitialized)
{
Debug.Log(spline.name);
Spline = spline;
Speed = 20;
}
}
}
Regards,
Siloni
I am new to Curvy and need help in accessing one existing CurvySpline from a custom script.
So, I have created one CurvySpline name "XYZ". And then created one cube and attached the below script to this cube. When I run the scene, I expect the cube to move along the spline.
In the below script, I dragged the curvy gameObject into the public variable "spline". But I am getting the error "NullReferenceException: Object reference not set to an instance of an object
TesterScript+<Start>c__Iterator35.MoveNext () (at Assets/Scripts/TesterScript.cs:11)
However, In the editor if I just add the SplineController script to the cube, then it starts moving along the spline without any issues. So, not sure what am I doing wrong.
Can you please help me !!!
using UnityEngine;
using System.Collections;
using FluffyUnderware.DevTools;
public class TesterScript : FluffyUnderware.Curvy.Controllers.SplineController
{
public FluffyUnderware.Curvy.CurvySpline spline;
// Use this for initialization
IEnumerator Start()
{
while (!spline.IsInitialized)
yield return 0;
}
void Update () {
if (spline && spline.IsInitialized)
{
Debug.Log(spline.name);
Spline = spline;
Speed = 20;
}
}
}
Regards,
Siloni