transform.FindChild returning invalid Transform?

I have two characters. Im trying to make it so one can pick up the other. Id like to get the transform of the IKRightHand from the rig and use that to position the character which has been picked up (or ideally get left and right hand and find the middle point etc).

private Transform righthand;

    protected override void CustomAwake()
    {
        righthand = controller.otherPlayer.transform.FindChild("IKRightHand");
        Debug.Log("Righthand: " + righthand);
        Debug.Log("RH Position: " + righthand.rotation);
    }

other player is a GameObject which I add to either character within the editor. My issue is that the first debug line shows that the righthand has been set to a UnityEngine.Transform (if it were null, the child didnt exist). However, the second debug line returns a NullReferenceException (this happens with rotation, name, anything). Why would this happen if the prior log shows that I have a valid transform component? Any ideas?

I don’t know if it helps you, but I got a NullReferenceExpetion lately too: the solution was to write in the “path” where to find this child exactly e.g. let’s say you have following bone structure:

Human->Arm->Hand->Finger and now you want to find the “Finger”. I had to do:

var finger = transform.Find(“Arm/Hand/Finger”);

that was the fix. Thanks!

Bump for this VERY odd fix to what, for me, is still a random issue in v3.5. I just encountered this (imo)bug, spent an hour trying to fix it, and find a solution. LUCKILY this thread fix was here, thank you to Marctro! :slight_smile: