» Tue Jun 19, 2012 3:57 pm
ah ok.
this is great because i'm actually working on something that is similar as well (when weapon is drawn it is a one-handed dual wield ninja sword, and when sheathed it is a double scabbard in X-formation on the back)
we would probably have similar scripts since i think they would work the same way.
i think the best way to start this is to set up a quest either through the story manager (so that it only fires when your character specifically adds the katana to his inventory) or you could set it up as a quest that starts regardless at game start (but it would be active regardless if the player has the katana or not)
in any case you could start your script by listening for an event: OnEquipped
the onequipped event is looking for the 2-hand katana to be equipped (which will then show the scabbard on the players back)
inside your onequipped event you may need to either use registerforupdate or a while loop.
i personally would prefer to use the while loop, since you need this action to perform in real-time
so, something like
while the 2-hand is equipped
if player has weapon drawn
remove 2-hand weapon
equip 1-hand weapon
the main problem with this is that by swapping meshes using a remove and add, you will not be able to temper the weapon as the stats will reset each time it is added back into the inventory. you also need to take into account the possibilities of other weapons being equipped, or if while you have the 1-hand katana equipped, the player switches to a bow (which forces the 1-hand to unequip), then unequips the bow (which forces the 1-hand back into the hand, but it wont fire the onequipped part of the script again, thus breaking the loop and it will not sheath onto the players back)