Motion Symphony 2.0 is a generic system, meaning that it does not force a specific configuration like MS1.0, where a ‘Trajectory’ was the main input for controlling the motion matching node. In MS2.0 it is possible to use different input response data as well as multiple input response types and therefore the input into the motion matching node cannot just be a trajectory, it needs to be more generic.
For Motion Symphony 2.0 we use a generic data type called ‘FMotionMatchingInputData’ which is essentially is a wrapper for a float array containing all the data from all ‘Input Response’ type match features.
Setting Up
In your animation graph you will need to create at least one variable of type ‘FMotionMatchingInputData’. This data needs to be initialized with the ‘Motion Configuration’ you are using so that it has the correct size for your setup and then that data needs to be updated and filled every frame to provide the appropriate control from the player to the motion matching node.This data can be filled via specific components depending on the type of ‘Input Response’ match features you are using. For example, if you use a ‘Trajectory 2D’ match feature, you can use the Trajectory Generator Component to automatically fill this input data. Follow these steps to adequately initialize and fill your input data at runtime.
Note: Since the Input Data is essentially a wrapper for an array of floats, it is technically possible to fill the data manually with any input response data. However, this method is only for advanced use cases. For the majority of uses, the data should be automatically populated with the available helper functions.
Step 1: Create a variable in your animation graph of type ‘MotionMatchingInputData’.
Step 2: In the ‘Update Animation Event’ use the helper function ‘ConstructMotionInputFeatureArray’ to fill the ‘InputData’ automatically depending on the available components and ‘MotionConfiguration’. This is shown in the below image:
Note: If you do not have the appropriate components attached to your character, this function will just fill the data as zero. Make sure you have the necessary components attached. See the next section for details.
Step 3: Use the Input Data as an input for your Motion Matching node/s:
Note: It may be appropriate to use different InputData for different animation nodes depending on your project. You are not limited to one. Essentially you want to have one InputData for every different ‘Motion Config’ you are using.
Components Required for Automatic Input Data Construction
In order for the ‘ConstructMotionInputFeatureArray’ blueprint function to work, it needs to be able to extract relevant data from components attached to your character, otherwise the data will just be ‘zero’ filled. This section describes which components are required for each ‘response type’ match feature to function.
Trajectory Generator
The ‘Trajectory Generator’ component is required for the following match features to work:
Match Feature Trajectory 2D
Match Feature Trajectory 3D
Distance Matching
The ‘Distance Matching’ component is required for the following match features to work:
Match Feature Distance
Character Movement
The ‘Character Movement’ component is required for the following match features to work:
Match Feature Body Momentum 2D
Match Feature Body Momentum 3D
Manually filling the Input Data
In some edge cases it may be desirable to manually fill the input data array or modify it. However, this is an advanced topic and should not be attempted unless absolutely necessary as the process is prone to error. Even in the case of custom ‘response type' match features, it is better to override the ‘SetInputData’ function on the custom match feature itself rather than filling the data manually.
Since the ‘MotionMatchingInputData’ type is just a wrapper for a float array, one can simple access the float array named ‘DesiredInputArray’ within the input data and modify it directly. In order to do so you must understand how the data is laid out for match features.
Data Layout
‘Input Data’ is laid out sequentially in order of the ‘response type’ match features listed in the ‘Motion Configuration’. Different match features have different sizes, and this must be taken into consideration. ‘Match Feature’ sizes can be seen on the pages for each match feature individually.
For example, consider a motion configuration as such.
Trajectory 2D with 3 trajectory points (Size = 4*3 = 12)
Distance Matching (Size = 1)
The data will be laid out with all Trajectory 2D data first followed by the Distance Matching Data. In this case, it’s obvious to see that the data for each match feature will be as follows:
Trajectory 2D: Index 0 to 11
Distance Matching: Index 12
To see how the data is laid out within each specific match feature, see the specific pages on each match feature. As an example the complete data layout for the described motion configuration would be as follows
PosX_0 | PosY_0 | FaceX_0 | FaceY_0 || PosX_1 | PosY_1 | FaceX_1 | FaceY_1 ||
PosX_3 | PosY_3 | FaceX_3 | FaceY_3 || Distance ||