Strafing locomotion is different in a few ways to regular locomotion and some changes in the motion matching system are required. This mostly relates to the trajectory generator and trajectory point facing angle. For strafing the facing angles need to be facing in the direction of strafe as shown in the below image.
Please see this video tutorial as a supplement to this section of documentation.
Trajectory Generator
Strafe Mode
The first step to setup strafing with motion matching is to change the ‘Mode’ of the trajectory generator component. To do this in the editor, change the ‘Trajectory Behaviour’ to ‘Strafe’
This can also be done at runtime by directly setting the ‘Trajectory Behaviour’ to Stafe as shown below:
Strafe Direction
In strafe mode, the strafe facing direction needs to be manually set on the trajectory generator. This can be done by explicitly setting the ‘Strafe Direction’ property on the Trajectory Generator as shown below:
Alternatively, a utility function can be used to set the strafe direction based on the camera as shown in the below image.
Angular Error Warping Component - Strafe Mode
If you are using the Angular Error Warping component then you either need to turn it off during strafe or change it to strafe mode as well. The settings should also be changed as follows to modify the behavior of the angular warping to better suite strafing
Note: If you have animations that enable the character to turn and change their plane of strafing then angular error warping can be toned down or turned off completely.
These changes can all be made at runtime by directly setting values on the Angular Error Warping Component:
Motion Data / Calibration
Setting up strafing animations in the motion data editor is no different from standard locomotion except that you might opt for using a different calibration altogether. Strafing motion is very different to 'standard’ and a shift in calibration weightings may be necessary. The below calibration is an example of calibration for strafing in the example project.
Note: ‘Weight Angular Momentum’ is only set to zero in this calibration because the example animation set does not contain any turning. As a result this weighting is redundant and has been set to zero for these purposes.
Note: Strafing calibration may differ from animation set to animation set. There are no hard and fast rules, rather “educated” trial and error should be used until the visual results are as desired.
Other Considerations
To further improve strafing animation with motion matching there are other considerations to be made as described below:
Clean Cut Loops
It is recommended that clean looping cycle animations be created and used for strafing. This goes for every desired speed in all 8-strafing directions. These loops should ideally contain 3+ cycles each to get a good variation in motion.
Blend Spaces
Motion matching can only ever play animations that it is provided with. This means that many angular movements may not be possible and this can be particularly noticeable if the player is using a joystick instead of WASD keys. To combat this, it is possible to use Motion Symphony’s ‘Blend Space’ support to achieve motion in many more directions than just 8. This method does require ‘clean cut loops’ as described above.
For more details on blend spaces and how to use them in Motion Symphony, please see the ‘Blend Spaces’ section of this documentation.