Download

Workflow questions for first person viewmodel animation

I have some questions about viewmodel (first person weapon mesh) and how it is handled in UE4.

  1. Does the weapon have to be part of the same mesh? I posed a weapon with a hands rig and only the hands rig with the holding animation appeared in UE4 after importing. The gun however did not.
  2. In the first person template the hands and the weapon appear to be separate meshes. How does that work for animated weapons? In HL2 one would export the gun + hands as one mesh, after animating
    them both together in the same scene in the modeling package. How does this work in UE?
  3. What is the default camera position of the player view in the game, in the first person template? The variables say 64 units above center but I would need the height above ground to set up a view in
    my modeling package.
  1. No, it’s typical to have them imported as separate meshes and even using separate skeleton assets. It’s just easier to swap weapons and keep the same hands, etc.

  2. You can attach the weapon to a hand bone, a custom gun IK bone or a socket with the weapon’s pivot (main bone) set to the world origin at export (removing any keys on that main bone), or simply sync up the separately exported hand and weapon animations in blueprint. I think the latter method is less typical, and I’ve not seen it done in UE4 tutorials, but I assume you would use something like sync groups.

https://docs.unrealengine.com/latest/INT/Engine/Animation/SyncGroups/index.html

  1. I can’t open the project right now, but try dragging and dropping the character blueprint into your scene - you should see the camera in there. Then open a side-on orthographic view and middle-click drag to use the measure tool… keep in mind 1 uu = 1 cm.

[QUOTE=BobJoel;514112]

  1. You can attach the weapon to a hand bone, a custom gun IK bone or a socket with the weapon’s pivot (main bone) set to the world origin at export (removing any keys on that main bone), or simply sync up the separately exported hand and weapon animations in blueprint. I think the latter method is less typical, and I’ve not seen it done in UE4 tutorials, but I assume you would use something like sync groups.

https://docs.unrealengine.com/latest/INT/Engine/Animation/SyncGroups/index.html

So, I would do this:

Have both weapon and hand animated in the same scence in modeling package, then separately export both weapon skeletal mesh and hands skeletal mesh, then do the same for any animation? Because just attaching the gun to the hand does not seem like a good idea with moving parts and detachable magazines.

I mention that workflow as a possibility within the engine, I wouldn’t want to tell you it’s advisable as I’ve never done it that way. :slight_smile: Do have a look at some content examples such as the first person shooter project to see how things are done there. The attachment method works fine, and so long as the bone you are attaching to in editor is the same bone you animate with it’s quite easy. As I mentioned, you just take your finished animation and delete all but the weapon + remove all keys on its top-level bone and re-position it to the origin.

Thanks I will try that

One more question about the camera height. The imported arms skeleton has a camera mount bone, at 165 cm height. But measuring the ingame pawn distance from the floor to the camera object center is 130 cm. Also the capsule that is placed by default is sunken into the floor by 30 cm.

fps.jpg

Changing the camera value to -64 puts it at the ground exactly. So I take it the real camera position is exactly above the root, 128 units? If that is the case, isn’t that a bit low? A real person would have lower viewpoint because of a slightly arched back, from holding a weapon at the ready, but half a meter lower seems awfully low.
Also I take it the bullets come out of the camera center? Not the weapon muzzle like in other shooters?

EDIT: 128 can’t be right. It would put the camera at elbow height on the default skeleton pose.

I don’t really understand how that is supposed to work on the modeling packages side. I’ll explain how I am used to do it, perhaps that will bring clarity to myself.

As for animating the hands, I do it like this:

  1. Export the mesh in a V pose.
  2. Pose the hands (the underlying skeleton) in an animation then export that.

Now this is where it is confusing the hell out of me. How do I need to setup that same procedure for the gun?

a. What is the V pose for a gun? Especially translation.
b. How to pose the gun and hands in the same scene file (scene = inside modeling package)? I want to animate them both together, multiple bones. So having the gun at the world zero and then later ghetto posing it as a socket on a player so it barely fits did not work out for me.
c. How to put the gun in the meshes hands so it it is all synced, especially with complex animations where the gun itself has a few bones? (I will probably figure that one out myself once I figure out a and b).

I wouldn’t take the dimensions in the first person shooter project as iron-clad - that’s definitely low for a camera in my opinion, but it’s easy to change the height in the character blueprint.

I would recommend grabbing Epic’s animation starter pack (or just the UE4 mannequin if you have it on your project) and using the same IK setup for the arms. They have a bone called IK_hand_gun that’s parented under root -> IK_hand_root. So first off, you could rig your weapon / all of its constituent bones to this special gun bone. Weapon specific bones like mag and bolt don’t get exported with the arms, and the same gun bone acts as the root of the weapon skeleton when it gets exported. Make sense? This is the way I do it, anyway.

You’ve got the reference pose on the arms correct. Animate your weapon/arms in the same scene like normal; possibly, you may need to do some extra steps like constraining the hands to your gun bone or vice versa depending on your software. Only once you are finished and ready for export would you then move the gun (via the special bone) to world zero. The axis the gun is aligned to depends on the orientation of the attachment bone, but I think facing down the positive X-axis is typical. By locating your main gun bone outside the arm hierarchy it’s possible to have the weapon switch hands in an animation / not act like like a simple attachment. I mention other methods, like direct attachment to a socket because a lot of games (think third-person) don’t need that level of functionality.

Note that the way Epic did it, IK_hand_gun occupies the same spot as the right hand bone. While rigging, you’d want to take care with the placement of the gun relative to its top-level bone so that the right hand can correctly grip whatever it needs to when the gun bone is aligned to the right hand’s bone. This way, you don’t need to apply any translation offset to align things in UE4 - you simply attach your weapon mesh directly to IK_hand_gun in blueprint. At worst, you’d maybe have to apply a 90 degree offset to fix the orientation.

I found the solution after spending a few hours retracing the first person setup from the template and considering what you said. What fixed it for me was that I had to move the weapon_mount bone, which was at world zero, to the grip bone of my gun for the animation sequence and it exported correctly. I have not checked if that will work once the weapon and all of its parts with be animated, but I guess that will be the case.

I guess I have to export the gun at world zero for the reference pose, then simply move the weapon_mount with the weapon grip when posing.
Spent the weekend figuring this workflow out. Your posts have been a great help.

IPv0Ge3.jpg

Feels great having this work.
(The gun and hands are marketplace assets, but I rigged it myself, and the animations are from scratch too)