Sword Mesh renderer script

hey guys. i have a character model that i made in blender and imported to Unity. it has a sword and an attack animation that is part of the armature that i want both in the character’s hand and put away while not in combat. I spent all day in Blender, but i couldn’t find a way to properly do that. So, i just put the sword (which i imported seperately) as a child object of the armature in Unity.

i want to have two swords on the model, one on his side and one in his hand. When in combat, i want the mesh renderer of the sword in the hand on. if its not in combat, i want the mesh renderer of the sword on the side on. do you think there’s a c# script or JavaScript for this? Thanks!

Yeah no problem :slight_smile:


   var swordBySide : MeshRenderer;
   var swordInHand : MeshRenderer;

   function EnterCombatMode() {
        swordBySide.enabled = false;
        swordInHand.enabled = true;

    function ExitCombatMode() {
        swordBySide.enabled = true;
        swordInHand.enabled = false;

Attach this to you character and then drag and drop the gameobjects of the two swords on the inspector and call these functions when entering and exiting combat mode by doing:


from another script on the same game object.