Hi… I’m writing a item wearing code. When I click the sword, it becomes Armature’s Right hand’s child, but it’s rotation changes and I can’t set it as I want it to be
code :
void OnMouseDown(){
if (GameObject.Find("Character").GetComponent<playerScript>().hand==false)//if hand is empty
{
transform.parent=GameObject.Find("Character").transform.Find("Armature/Middle Spine/Upper Spine/Arm-R/Elbow-R/Hand-R").transform;
transform.root.gameObject.GetComponent<Animation>().CrossFade("Hold");
transform.localPosition=new Vector3(0,0,0);
alindi=true;
transform.rotation= new Quaternion(0,0,0,0);
GameObject.Find("Character").GetComponent<playerScript>().el=true;
GetComponent<Rigidbody>().isKinematic=true;
}
}