How i can add my animated weapon to the character ?

Hello,i need your help please. Im looking for my question for about 1 month now, i can’t figure out how i can add an animated weapon to my full body character (its an multiplayer FPS game but i need it for the shadow and other player view) all the post that im reading just talking about make the gun model child of the hand but what if my gun model have animation like bolt moving or reloading ?
For the FPS view i made it work perfectly but for the full body its another thing (i need to use a layer for running and walking at the same time)
Actually im using Blender for doing my animation, i tried to do the gun animation inside the full body rig but its made problem for blend it to another full body rig without the gun bones, i don’t know what to do it seems like no one want to have a animated gun in their tps body.
For the futur i would like to use the same full body rig with different weapon and animation for each of them, maybe i can animate in blender in my full body model, and separate the armature of the gun and the character model and add the gun model to the hand bones inside unity but i don’t know how to that and keep the same animation (not easy to animate a gun without the hand for reference)
sorry for my terrible english its not my natal language but i hope you understand.
Thanks for your help.

You already have the answer, make the weapon root joint child of the TPS hand/wrist joint, if you want to play an specific animation of the weapon just call it at the right time as you call any other animations at their right times.

If your weapon have a recoil animation you will need to synch the animation with the TPS skeleton but this is done on an extrenal program (unless unity have some IK system in place to drive the arms with the recoil from the weapon animation).

I don’t know how i can separate the gun and arm animation, actually they are part of the same armature/animation clip, and i don’t really know how to animate separatly the gun and arm (actually i know but it will remove my hand from the blender project so animate a gun without the hand for reference it’s kinda difficult) or maybe i just don’t understand your answer and i can’t just parent the hand to the gun because the gun have some animation like the mag moving, thats why i need 2 animation, or one combined without destroying the blend or the character rig for the futur

ok, you want to use different guns with the same full body rig, if I was in charge of said work I will definitely separate the full body rig from any gun, that will make the animation work easier, HOWEVER you can have the gun conected to your full body rig and hide the gun mesh while using a different gun in the game.

I’m a Maya user but the same principles can be used in blender, try this:

  1. separate the gun from the full body rig and export both files individually (full body rig without gun and gun without fullbody rig)
  2. start a new scene and import both files into the same scene
  3. make sure your gun is in the correct place and then create a constrain where the hand/wrist joint drives the gun root joint
  4. Make your animation and when you are done bake the animation to the full body rig and to the gun rig aswell
  5. export both files

At this point you will have the synchronized animation in both the gun and full body rig, now import them into unity and make the gun child of the full body hand/wrist joint and place the gun in the right place, now when you play the animation it will be perfect, you can do this for any gun/weapon and this way you can have all the guns you want in a very controlled and clean way.

2 Likes

Nice, but i don’t get the part when you say add the animation to the full rig and the gun, do i need to create 2 animator controller ? Also i have some IK in blender and hand parented to the gun i hope it doesn’t gonna break the anim. Thanks for your time, i search for month and didn’t tought about that…

@WGR is 100% correct with the process he detailed, and I agree with him that solution is the best solution to use.

However - another solution (not the best) is to keep exactly the same set up you have when you first posted, and separate the animations out in Unity by using animation layers. The second layer will need to be set to additive or override. The second layer will need a avatar layer mask to only include the arm/hand/gun. So the body will animate walking/running/idle or whatever while the shooting can happen at any time - while the other animations are playing.

You will still need to come up with a set up to properly switch out weapons - if you have multiple weapons in your game. Hiding the weapons by deactivating the skinned mesh renderer is one solution, although probably not the best solution.

If you are not aware of animation layers, avatar masks and layer masks - these features are fully documented in the documentation and animation learning material.

Thanks, i will try both, but i think the perfect thing for me its to add the fps animation to the rig tps (he share the same arm rig without body) but its only for a gain of time. Also, what do you suggest for the weapon switch ? I mean desactive/reactivate the mesh renderer made the anim controller do the default animation (after thinking i think the best way is to have 2 anim controller for the body and arm, so i don’t have to touch the body animation each time i switch weapon) but if you have any suggestion i don’t say no, thanks again guys !