I need to be able to change the parent of an object in a blender character model while in game. For now I have two models, one with it bound to the hand and one where it's bound to the back. I'm trying to use this script to deactivate and reactivate the two models mesh render.
if(Input.GetButton("f"))
//Sets the Boolean to true to activate animation.
animator.SetBool ("Sword", true);
//Sets the Chracter model with sword bound to hand to true.
SwordOut1 = GameObject.Find("Gamemodel Sword Combo")
SwordOut1.GetComponent().enabled = true;
//Sets the Chracter model with the sword bound to the back to false.
SwordOut2 = GameObject.Find ("Gamemodel Combonation")
SwordOut2.GetComponent().enabled = false;
}
else
{
//Sets the animation to not play anymore.
animator.SetBool("Sword", false);
//Sets the Chracter model with the sword bound to hand to false.
SwordIn1 = GameObject.Find("Gamemodel Sword Combo")
SwordIn1.GetComponent().enabled = false;
//Sets the Chracter model with the sword bound to hand to true.
SwordIn2 = GameObject.Find ("Gamemodel Combonation")
SwordIn2.GetComponent().enabled = true;
}
If you know any other way to fix this script or how to change the parenting of an models object than please reply.
↧