I have an empty go called “n14_SplineController” in my scene. Yet when using GameObject.Find from a script on another object, it returns null.
As you can see, I have a debug.log in place, which confirms its null. Then all errors break loose as I try to use the var SplineParent in my code.
Context: I’m using the Hermite Spline Controller (from the Unify community site) to have a point light move along a path once its instantiated from Resources. The script posted is attached to the point light prefab. I can’t define the var SplineParent by dragging into the Inspector, because once its in Resources it won’t let me. I also tried tagging the “n14_SplineController” and finding by tag as well as putting the code in Awake instead of Start, all to no avail.
var SplineParent : GameObject;
function Start()
{
SplineParent = GameObject.Find("n14_SplineController");
Debug.Log(SplineParent);
SplineParent.SetActive(true);
mSplineInterp = gameObject.AddComponent(SplineInterpolator);
mTransforms = GetTransforms();
if (HideOnExecute)
DisableTransforms();
if (AutoStart)
FollowSpline();
}
…the script continues from there.