- Home /
Weapons for 3D character
Hey, I'm getting ready to add weapons (guns) to my character and am wondering what the best way to go about this is. I've done searches and looked at examples trying to find out how best to set this up.
It's not for an FPS, so the animations are important. I'm using Maya, and not the Unity animation/rigging.
So the easiest way I can think of is to model a weapon into my character model, and then switch out the material (from invisible to texture) when the weapon is selected. I will only have a few weapons in the game so this might work. Still this seams like a really stupid way to do it.
I have tried to parent objects to my character in Unity but can't get them to animate with the character. Is this because I'm using an external application to create my animations?
What would be the ideal workflow for adding weapons to a character in Unity? Thanks!
Would working with the Unity animation tool provide more options and features in Unity?
Working with $$anonymous$$echanim will definitely help with transitioning between animations. There is a lot you can do with $$anonymous$$echanim that you can't do with the normal animation system. However, it will not help with attaching a weapon to your rig.
Answer by CG-DJ · Aug 30, 2013 at 08:03 PM
Hello,
Yeah, making invisible textures for weapons is definitely not the way to do it. Make the weapons as individual models and then parent the model to the bone you want the sword to follow. When I make animations like this in Blender, I add a special hold bone just in front of the palm, where I want the handle of the sword to be. Then I import the sword into the project in Blender, attach the sword to the bone, and make my animations. Then, when I export to Unity, I only export the character, not the weapon. Then, when I attach the weapon to the bone in Unity, the animations behave just like they do in Blender. The same basic idea should work in Maya.
Now, depending on the different weapons you have depends on how many animations you need to make. For example, if you have multiple swords, try to make it so that the same attack animations will work for each sword. If you have different types of weapons (i.e. axes, maces) then you probably (but maybe not) will want different animations for each weapon type. However, you may not have to make different idle animations for each weapon type, since you can basically hold a sword, ax, or mace the same way.
Now to switch between weapons, I'm a little at a loss there. I have never had to do that, but I'm sure someone else can help you. However, I know there is an easy way to do it. It may be just instantiating the weapon at that spot every time you switch weapons, or it could be you have all the weapons attached to the bone, but you have them disabled until you need them. I don't know.
Good luck with your game! (and be sure to vote up if it helps)
Awesome, parenting the object to the bone is exactly what I needed to do!
Now to switch weapons, yeah I'm back to the invisible texture or enable/disable object idea.
I'm sure there must be a better way to do this. Will continue to read up on this now that I've got the parenting working.
I'm 99% sure invisible textures is a bad idea. If no one else comments in the next few hours, ask a new question specifically about weapon switching.
Although, before you do that, make sure you do a thorough google search, looking for things like "unity mmo weapon switching" or "unity weapons switch"
I agree. I think the only downside to invisible texture would be the extra performance hit of all the hidden objects. $$anonymous$$y character is pretty small on the screen so a few hidden low poly objects may not be too bad in this case.
I know it's not optimal, just gotta find a legit way to do it.
I'm pretty sure I could spawn the object (with a specific rotation) as a child of the bone, and then remove it...
$$anonymous$$ake the weapon have a local position of 0,0,0 position and rotation. Instantiate it, parent it, move to pivot (bone), set its transform to zero. OR. Even better would be to have them lying around somewhere hidden in a pool, and swap them back and forth from there. Depends on the situation.
Answer by dannidam · May 14, 2015 at 02:02 PM
as far as i know if you don't have a attach bone from Blender or Maya, you can also attach GameObject"mount".. to you character in unity this way you can also control the attachment, and it should follow your animation. - although i think that you need to attach it in Blender/Maya also to make proper animations..