Attaching mesh to hand makes the mesh disappear

Hi,

I am fairly new to Unity so please forgive me if this question has been answered before. I am still a noob! :slight_smile:

What I want to to is build an interactive world where the player can pick up objects.

I have a pair of hands visible and attached to a FPS controller and I need any interactive object that the player clicks on to become attached to the hand bone.

I have looked around the forums and have seen recommendations of parenting the mesh to the player hand so I thought it would be fairly straight forward.

My code inside the interactive object is:

 // H2 is the actual bone that I want to attach 
 // the object to...
 leftHand = GameObject.Find("hand_left/H2");

        gameObject.transform.parent = leftHand.transform;

However when I do this the object seems to parent itself to the hand in the hierachy window but disappears from view.

I have tried to look at the scene in wireframe just in case the mesh was being attached in the wrong position…It seems to attach itself initially (not in the intended position) and then just disappears even though it is visible in the hierachy inspector.

Am I doing something wrong? Any help would be appreciated.

Go to the Scene view while the game is running, select the vanished object, move the mouse over the view and press the F key. This should zoom in on the object if it is there. You’ll likely find the object moving around somewhere in the scene. If so, it means the object’s position is incorrect. You can use the object’s transform.localPosition to set its position relative to the hand.

Thanks for the assistance. I made the recommended change to localPosition and it works great. :slight_smile: