Instantiated object's scale or position changing?

I have very simple code to instantiate a prefab object that is set like so many tutorial examples I am currently following.I am finding however, that my object below has a scale changed to (2, 2, 2), instead of (1, 1, 1).
My start position and scale, also i have parent object “Hand”
4164589--367597--Без имени-4.jpg

will change4164589--367600--Снимок.JPG

I create instance

EquippedWeapon = (GameObject)Instantiate(Resources.Load<GameObject>("Weapons/" + itemToEquip.ObjectSlug),
            playerHand.transform.position, playerHand.transform.rotation);

EquippedWeapon.transform.SetParent(playerHand.transform);

I try change woroldPositionsStays, scale don’t change, but position will change.

EquippedWeapon.transform.SetParent(playerHand.transform, false);

You can use localPosition or localScale to affect the values after parenting.

why did it happen ?
and
Please, example, how set value(position and scale) to my hand parent ?
or
How can I, use localscale from my prefab instance ?

Vector3 v = EquippedWeapon.transform.localScale;
        EquippedWeapon.transform.SetParent(playerHand.transform);
        EquippedWeapon.transform.localScale = new Vector3(v.x, v.y, v.z);

I’s good idea?

When I change my Hand(paren) - position, it so good, but now when i change position or rotation, instance sword mesh hand and prefab become garbage.

Are you setting the values for a prefab or an instantiated clone? What is the scale of your Player and Player_Model objects? Do you need a direct linear hierarchy?

I would try to keep all of your scales at 1,1,1 for consistency if possible.

4167490--367984--Без имени-1.jpg
I instantiate simply prefab (clone).
I want find correct solution. I don’t know linear hierarchy or not, how better?

OK, so the Player_Model has a scale of 0.5, which will affect all of its’ children as well. If the sword’s scale is wrong at 1.0, you can try just explicitly setting it to 0.5 after parenting so that it matches the Player_Model’s scale but not the Hand’s scale… or alternatively, correct the issue with the Player_Model so that all of your scales are 1,1,1 which is the ideal setup as scaling objects like this will affect everything: particle systems, colliders, the physics system, etc.

1 Like

Ok, I understood, what all depend from my parent (and up hierarchy)
But, last question:
I stand explicitly scale - it’s ok work when i call instance, but then rotation and position change, instance take only scale property.

There’s localPosition and localRotation for explicitly setting only the child’s local values rather than in world values. Is that what you mean?