Selecting transform in FBX hierarchy csharp script

I am trying to set a transform called _target to an object in the hierarchy of a FBX object using csharp script.

I’ve got my script so that it selects the correct gameObject in the hierarchy of a FBX object. In this case it is Spine001_00.

Transform test;
test = transform.Find("Spine001_00");
Debug.Log(test);

Debug.Log(test) gives the result on the console window of :

Spine001_00 (UnityEngine.Transform)
UnityEngine.Debug:Log(Object)

The following lines of code set test to _target and _target to transform.

_target is used throughout the script to determine the transform (co-ordinates) of the camera target.

	test = _target;
    _target = transform;

Running the game with the Play icon sets _target not to the root of my FBX and not to Spine001_00 (which is one level down the hierarchy).
I can select Spine001_00 or any other object in the hierarchy (I’m selecting bones which are read by Unity as gameobject type), and the target adjusts itself fine during run-time, but I still need to manually select it when the code written is for it to be automatic.

  • Unity loses the focus of _target in
    the component editor on the inspector
    at run-time (ie _target is NONE) if the code is changed from

    test = transform.Find(“Spine001_00”);

to

   test = transform.Find("/Spine001_00");

which gives the result on the console window of

null UnityEngine.Debug:Log(Object)

Alright, I have got it working now. I’ve put the camera and tracker creation into myThirdPersonCamera script. It works both in the game window and in build and run.