- Home /
How can I change sword?
I have a character with whom there are three kinds of sword,
and I want the first sword upgrades to the second one.
So I need to change sword.
I have come up with the idea that I can use the INSTANTIATE function - destroy one and
instantiate another at the mean time.
So I am wondering if it will work out and if there is a better solution for my situation.
My English is poor so I wonder if I made sense..
Thanks in advance!
Answer by ZanzibarDreams · Mar 24, 2010 at 09:13 AM
As you said you can instantiate a sword, position it and pose it at his/her hand-bone(whatever you are using). Another way ( which i prefer ), is having all the swords parented under the character, then using code, only make the sword you want equipped visible. This has the advantage of easier positioning, and you can animate the sword in his hand as well!
At the appropriate time, use :
(yourCharacterObject) .transform.Find( path ).renderer.enabled = true;
to show a child model
the path is a string and looks something like this
"root/spline1/spline2/spline3/Rshoulder/Rarm/Rforearm/Rhand/Rfinger/REND/AwesomeSword"
depending on the setup of your bones.
Your english is fine!
Good luck!
Answer by qJake · Mar 24, 2010 at 07:29 AM
There isn't a right or wrong way to do things in Unity. And what I mean by that is, there could be multiple ways of doing something that are all the "correct way". Try and avoid asking questions like this here (i.e. "Is this the right way?") because there is no definitive answer. Yes, your idea will work, but this is more of a discussion-type question than a straightforward answer, and is probably better suited for the forums than here.
See the FAQ for what this site is (and is not):
I think it's an O$$anonymous$$ question to get two different methods on how to swap a sword...! But even if you're right this post should be a comment.. it's note exactly an an answer that Jin is looking for.. :) He already knows that it's working..
Your answer
![](https://koobas.hobune.stream/wayback/20220612125447im_/https://answers.unity.com/themes/thub/images/avi.jpg)