# How can I make an attached gameobject behave correctly on character flip?

I have a character that on start-up is equipped with another gameobject/prefab as a weapon, attaching it to a hand.

void Start()
{
handFront = transform.Find ("root/Hip/BodyBone/OverArmFrontBone/UnderArmFrontBone/HandFrontBone/HandFrontMount");

instance = (GameObject)Instantiate(Resources.Load<GameObject>("VioletClub"), new Vector3(-0.5f,2f,1f), new Quaternion(0f,0f,45f,-45f));
instance.transform.parent = handFront;
}


As long as I move the character in the initial direction (right) the attached object behaves as it should, staying in the hand no matter the animation played. But when I flip the character, the attached object doesn't flip correctly. In the initial position (standing still) it looks correct but when I start to move the character, the item flips and rotates the wrong way. It does not follow the arm movement like it should.

This is what I do on flip:

void Flip ()
{
facingRight = !facingRight;

Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;

}


When I flip the character back to the right again it all work as it should.

Can anyone help me?

• Have you tried also flipping the children? With something like foreach(Transform child in transform)? – MichaelHouse Apr 8 '14 at 15:31
• Yes. I have tried flipping the children. That didn't do the trick. – seddler Apr 8 '14 at 15:49
• Perhaps try detaching the children before the flip and reattaching after the flip is done? – Tetrad Apr 8 '14 at 16:09
• That didn't seem to work. – seddler Apr 8 '14 at 16:30