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

All games are different and have different requirements for locomotion and traversal. Therefore it is impossible to create a trajectory generator that covers every single game. Motion Symphony supports and encourages the creation of custom trajectory generators that suite specific needs.

There are two methods of making custom trajectory generators and, while it is possible to create one with blueprint it is recommended that all trajectory generators be created in C++ for best performance.

Trajectory Generator From Scratch

If you desire to make a trajectory generator from scratch there are no limitations to the way you do it. As long as it generates a Trajectory (FTrajectory) structure that can be used as an input on the Motion Matching node. Each trajectory point position and rotationZ must be relative to the character’s current transform taking into consideration UE4’s 90 degree rotation on character models.

Trajectory Generator Base

It is much easier to create a custom trajectory generator by inheriting from ATrajectoryGeneratorBase. By doing this you take advantage of the following features:

  • Automatic recording and extraction of past trajectory

  • Automatic trajectory extraction

  • Use the same blueprint functions as the default trajectory generator

  • Override a single function for future trajectory prediction.

  • Input Profile functionality

If you desired to create a custom trajectory inheriting from the ATrajectoryGeneratorBase class, it is recommended to look at the source code in Data/TrajectoryGenerator.h and Data/TrajectoryGenerator.cpp for details on how it was done for the default trajectory generator.

Note: Custom trajectory generators are an advanced topic and it is expected that users attempting this will have the knowledge required to develop one based on the existing code.

Trajectory Space

To simplify the generation of trajectories, all trajectory generators should create a trajectory in Trajectory space. This is different for both past and future trajectory points.

Past Trajectory Space

Past Trajectory points should be recorded in absolute world space. The ‘TrajectoryGenerator_Base’ class will automatically convert this into the character’s space when the ‘ExtractTrajectory’ function is called.

If you are not using the TrajectoryGenerator_Base you will need to transform the recorded past trajectory into your character space taking into consideration the 90 degree rotation that character models have in UE4.

Future Trajectory Space

In order to simplify the logic of future trajectory generation, points should be generated independently of the character from position (0, 0, 0) based purely on the Input Vector. When the trajectory is extracted at runtime the ‘TrajectoryGenerator_Base’ class will automatically transform the trajectory points (transform vector direction only) into the character space when the ‘ExtractTrajectory’ function is called.

If you are not using the TrajectoryGenerator_Base you will need to transform the future trajectory point vectors into character space, taking into consideration the 90 degree rotation that character models have in UE4. Since the trajectory was generated from (0,0,0) world position, the absolute world position does not have to be transformed, only the direction of the trajectory vectors. In this case InverseTransformVector can be used instead of InverseTransformPosition.

Note: If you want your trajectory to generate based on your current camera angle, the movement input vector needs to be transformed based on the character direction before generation. This is usually done in blueprint.

{{{ content }}}