Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not able to access existing spline from custom script
#1
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
Reply


Messages In This Thread
Not able to access existing spline from custom script - by silonighora - 12-02-2015, 05:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
  Adjust radius of generated mesh via script? Shackman 1 4 03-26-2024, 01:12 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_

Forum Jump: