Trajectory Generator Component {{ currentPage ? currentPage.title : "" }}

The simplest way to generate a trajectory is to use the built in ‘Trajectory Generator Component’. This is an actor component that sits on your character actor and can be used to automatically generate a trajectory every frame for your motion matching needs.

It handles recording of the past trajectory and generation of a future trajectory based on user input.

Adding the Trajectory Generator Component

To add the trajectory generator component, click on the ‘+ Add Component’ button at the top left of your character blueprint’s components tab. Search for ‘Trajectory Generator’ and select it.

Initial Setup

To control the behavior of the trajectory generator, you will need to modify the settings in the details panel. Select the trajectory generator and go to the ‘TrajectoryGeneratorBase’ heading.

Step 1: Set the ‘Motion Match Config’ asset under the “Trajectory Generator Base’ heading. This is required for the trajectory generator to function. The trajectory generator needs to know how many points to generate and at what time intervals to generate them for. It cannot do this without the Motion Config.

Step2: Set the ‘Max Speed’ of your character under the ‘Motion Settings’ heading. This will effect how long the trajectory is.

Details Panel

The details panel has a number of settings that will change the behavior of the trajectory generator.

Max Speed - The maximum speed of the trajectory(cm/s) when user input is at maximum. This will affect the length of the trajectory. This is NOT the speed of your character and does not affect movement. It is simply the max speed of your animation set’s root motion.

Note: If there is a mis-match between the length of the trajectory and trajectories in your database then it will struggle to match consistently. Ensure that you match the trajectory speed to your animation data even if you aren’t using root motion.

Move Response - How fast the trajectory will respond to changes in position. The higher the value the faster it will respond, while the lower the value the slower it will respond. Tweak this value until you get the desired result. Obviously faster trajectories will lead to more responsive animation.

Turn Response - How fast the trajectory will respond to changes in facing direction. The higher the value the faster facing directions will change, while lower values cause them to respond slower. Tweak this value to attain the desired result..

Note: For best quality results, try to tweak the Move Response and Turn Response to match the responsiveness of your source animation. If you want to improve the responsiveness of your animations you can make these value higher but be aware that quality will be affected.

Reset Direction on Idle - If checked, the facing direction of the trajectory points will reset back to the current facing of the character when there is no input. This is required to stop the character abruptly turning as they stop. Uncheck this box if you want the character to turn when stopped in the direction the trajectory was facing before no input.

Note: In most cases ‘Reset Direction on Idle’ should be left checked as it could cause jitter otherwise. Specific animations are required for it to work correctly without jitter.

Motion Match Config - The Motion Config asset used for your motion matching nodes in the animation graph. This is required to ensure that the trajectory being generated is the same as those used in the animation graph.

Recording Frequency - The rate at which historical movement data is recorded for ‘past’ trajectory generation. Setting this value to 0.0 (default) means that the character’s historical position will be recorded at 30Hz.

Sample Rate - The trajectory generates a dense set of trajectory points at a specific rate to improve consistency and accuracy. The sample rate is the number of iterations that the trajectory logic is run in order to generate a complete trajectory. The final trajectory is later extracted from these samples.

Flatten Trajectory - Check this to ensure the trajectory is flat when extraction takes place. This is part of the trajectory generator base class and it can be used to flatten a trajectory (Z = 0) during extraction if the inheriting trajectory generator does generate trajectory data on the Z axis.

Debug Random Input - If this is checked, the trajectory generator will be fed random input for testing purposes. If set up correctly the character should run around randomly stopping and changing direction at specified intervals.

Debug Time Interval Range - A time interval range between random input changes (see above). For each input change a new time will be randomly taken between these values until the next input direction changes.

{{{ content }}}