Weapon Poses & Aim Offsets - DrowningDragons/MoveIt-Wiki GitHub Wiki
Outdated - New Tutorial Coming Soon
How the Weapon Pose System Works
When you change weapon MoveIt detects this and caches existing poses and then blends seamlessly to the new weapon's pose so that you don't have snapping like the more basic systems. It also layers the weapon's pose over the existing animation set. If you want to understand the system better, or remove the weapon layering in favour of dedicated weapon locomotion animsets, then this is the responsible part of the animation graph:
Proper Utilization
Weapon Class
Your game should naturally have a base weapon class, and you will want to add MIWeapon
struct to the base class. This provides you with these options for each weapon:
- Weapon Mesh
- This should be the mesh used by the weapon
- Off Hand Socket Name
- This is used for grip placement of the left-hand
- Is One Handed
- Grip placement and animation layering for left arm is not used if this is true
- Weapon Pose
- Actual weapon pose animation asset
- Aim Offset
- Actual weapon aim offset asset
Character Class
In your Character inheriting from MICharacter
you will want to override the function Get Weapon Anim Info
, get the currently equipped weapon which should now contain the struct above, and simply return the struct.
Make sure to null check with Is Valid
and just return nothing if you have no weapon.
Weapon Animations
Even though MoveIt seamlessly blends weapon poses, it is going to look better if you add switching / unsheathing / sheathing animations of course.
If your weapon has a custom animset that you've added directly to the locomotion and don't want the pose system, then while that weapon is active on tick just set Use Weapon Pose
to false.
Aim Offset
The aim offset is comprised of two parts - a traditional aim offset and also bone rotation compensation to compensate for the turn in place.
If you click on the Aim Offset Compensation
node in the animation blueprint you can change which bones are rotated.
If your bones are rotating the wrong way, either because you have a non-UE4 character where X isn't the aim axis, or perhaps you have a creature on all fours you may need to change the Aim Axis
to have it compensate correctly.
Aim Offset Settings
You can change the rate at which the Aim Offset interpolates, as well as the compensation rate and the compensation amount for each direction.
The compensation rate in particular is worth playing with if you don't feel that the weapon is correctly aiming at the screen, but setting it too high can cause snapping.
Off-Hand Placement
Placing the hand is very easy. The weapon just needs a socket added that matches the name used for Off Hand Socket Name
in MIWeapon
, and you can adjust it while you're playing the game. The best way to set it up is to add the socket, equip the weapon, then adjust the socket location and watch the hand move around in real-time until it is perfectly positioned (and then save the weapon!).
These nodes are responsible for the placement of the off-hand. By default, Enable Hand IK
is true if the character is armed (has a valid weapon mesh) and Is One Handed
in MIWeapon
is false.