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

The simplest way to generate a trajectory ‘Input Data’ 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.

Strafe Direction - When using the trajectory in ‘strafe mode’ the system cannot determine the ‘strafe’ facing direction directly based on user input and this needs to be updated manually. In most cases this strafe direction is based on the ‘players’ camera and can be set in the ‘EventTick’ event on your character blueprint as shown below:

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.

Trajectory Model - The trajectory generators have two movement models that can be used as follows:

  • Spring - Spring mechanics are used to generate a trajectory based on the motion settings on the trajectory generator. This is generally better if you are using RootMotion and it may be a good idea to start with this mode first.

  • UE5CharacterMovement - This mode emulates the UE5 Character Movement component so that the trajectory matches correctly with UE5 movement. All movement parameters are taken from the character movement component rather than the trajectory generator. Be aware, that if your character moves too fast, the trajectory provided from this mode will not be good for motion matching. You will have to tweak the movement component settings until you find an adequate balance between responsiveness and quality.

Trajectory Behavior - This setting is used to define how the trajectory must behave. There are two options:

  • Standard - Trajectory facing rotates to point in the direction of movement (follow your nose movement)

  • Strafe - Trajectory facing is controlled manually by the user in order to achieve a strafe type movement.

Trajectory Control Mode - How the trajectory should be controlled. There are two options:

  • Player Controlled - The trajectory is controlled via player inputs which must be set in your character or controller blueprint

  • AI Controlled - The trajectory is controlled via AI Navigation. By default, this will simply point the trajectory towards the next point in the AI navigation path. For a more advanced AI trajectory, also tick the ‘UsePathAsTrajectoryForAI’ option.

Use Path as Trajectory for AI - If checked, the trajectory generator will construct the trajectory along the AI navigation path taking into consideration multiple points in the path instead of just the next one. Trajectory Control Mode must be set to ‘AI Controlled’ for this to work.

Draw Trajectory - If checked, this will draw the full trajectory in the editor for debugging purposes.

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.

Draw Trajectory - If checked, debug trajectory will be drawn during play-mode. Note that this is the high resolution trajectory generated by the trajectory generator, not necessarily the trajectory used by your motion matching node. The motion matching node only takes a sample of this trajectory based on the motion config used.

{{{ content }}}