- Home /
Cannot move or rotate child Object
I have an odd problem with Unity. I got a Swords Prefab and a Character with a sheath on the back. The sheath has a bone where the sword should be.
Now i parent the Instantiated Sword Object to the Sheath bone, which works just fine (i think?!). Now i have to Rotate the sword for 90degrees so that it fits perfectly in the sheath. But i cant change the rotation or position of the sword in the script. I`ve tried localPosition, position, rotation, localRotation, eulerAngles, localEulerAngles, nothing works. I can rotate the sword in the scene - view though. The sword model was imported from blender...is it important wich pivot i use there? Or could something different went wrong there?
Here is the important part of the script:
public Transform Swords;
public Transform rightSheath;
void Awake ()
{
Transform swordR = (Transform)Instantiate(Swords, rightSheath.transform.position, rightSheath.transform.rotation);
swordR.transform.parent = rightSheath;
movement.direction = transform.TransformDirection (Vector3.forward);
controller = GetComponent<CharacterController>();
Spawn ();
}
Answer by kievar1983 · Jan 02, 2012 at 12:01 AM
it sounds like the game is not finding your object, can you move the object around on the screen? I'd try to do that before any rotation. also most likely with the rotation unless you know the precise math behind it you are probably going to want to use matrix or quaternion rotation and not a locale rotate or rotation.
Answer by puelo · Jan 02, 2012 at 12:18 AM
I see the sword on the back of my character when i start the game. When i switch to sceneview i can select it and rotate / scale and reposition it, without problems. I will maybe try to delete the prefab and reimport everything..
Answer by puelo · Jan 02, 2012 at 12:17 AM
i tried to import the sword once again with other rotation and was able to import it so the rotation fits to the Sheather......nevertheless the problem with me not able to rotate the object in the script is still present...what do you prefer to use to rotate the Object to a certain angle?
Answer by puelo · Jan 02, 2012 at 02:55 PM
It seems that i am not able to move the Object at all, even if its not parented.. Its not static.
Your answer
![](https://koobas.hobune.stream/wayback/20220613062600im_/https://answers.unity.com/themes/thub/images/avi.jpg)