Once the ‘Trajectory Generator’ is properly set up on the character blueprint, it is time to set it up on the animation graph.
Access the Trajectory Generator Component
Before using the trajectory generator in the animation event graph you will need to access the trajectory generator component that lives on the character actor. It is recommended to cache the component in a local variable to avoid having to retrieve it every single frame.
Extracting the Trajectory
Since the trajectory is generated with a dense set of points / iterations for accuracy, we need to extract only a portion of the points that match the Motion Configuration for motion matching.
Step 1: Create a Trajectory variable in your animation blueprint of type ‘Trajectory’ (FTrajectory if creating a custom C++ AnimationInstance).
Step 2: Call the following function from the Trajectory Generator component and set the trajectory
Motion Matching Node Input
Once the trajectory variable is set, it can be used as an input to the ‘Motion Matching’ node as shown below:
Checking If The Trajectory Generator Has Input
Sometimes it may be beneficial to determine if the trajectory generator has movement input or not (i.e. input vector is 0, 0,). This could be used to inform state machine transitions (e.g. transition to and from idle state).This can be done with the following function call: