Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Importing an FPS hands viewmodel with weapon as a single animated object

Discussion in 'Animation' started by loxagos_snake, Oct 2, 2023.

  1. loxagos_snake


    Mar 8, 2015
    Whenever I Google this question, I get completely unhelpful results, so I decided to ask here.

    I am making an FPS game that has a separate worldmodel (3rd person view) and viewmodel (1st person view) for the character, similar to how games like Counter Strike handle it. This means that I have to animate the representations of the character separately, so after doing some research, I found out that viewmodel animations are created on a weapon-by-weapon basis: basically, you take your rigged 'hands' model, bring in the weapon you want to animate, and utilize constraints + IK to have a synchronized motion.

    Being a programmer and not an animator, I followed a tutorial to test this out (I will not be making the final, polished animations myself) since I want to figure out the Blender to Unity workflow. I rigged the hands and the weapons separately, added control bones for the appropriate vertex groups, and constrained the hand bones to 'follow' the gun. So now, when the gun shoots/reloads/wiggles around, the hands follow with minimal extra intervention. I actually got a decent-ish result, too.

    But now I can't figure out how these objects should be treated inside Unity. If I export them as .fbx files along with the animations, they are two separate pairs of rig + mesh, so I'd have to set up the animations separately as well. Ideally, I'd like them to be a right so I can treat each viewmodel as a complete entity and provide only one set of animations per viewmodel. The 'obvious' action of joining them in Blender simply breaks the animations.

    I downloaded a free model of hands holding a rifle to study it, and despite the meshes of the hands and weapon being separate, all animations move both of the GameObjects. But I can't figure out how they did it. Do you have any ideas, or even better, a tried workflow you could suggest? Most resources online are either just parenting the gun to the hands via code or explaining how to do procedural animation, neither of which are my goal as I prefer having the control that modeling tools give you.