In order for the trajectory generator to work, the player input (or AI input) needs to be fed into the trajectory generator every frame or at specific time intervals (e.g. 30Hz).
Setting Trajectory Input
Below is a simple example of how to set the trajectory input on Tick.
Note: This is only an example, you don’t have to perform this on tick. It could be at certain time intervals (e.g. 30Hz) and the method of getting your input values can differ.
How you get your movement input and call this function is up to you and you may wish to do it differently.
Make the Trajectory Camera Relative
For player controlled characters, it will often be desirable to make the trajectory generate relative to the camera Yaw rotation. This is done by simply transforming the input vector relative to the camera yaw. Motion Symphony provides a utility function to perform this, but you could do it any way you like as an alternative.
Changing Trajectory Generator Settings At Runtime
It may be necessary at times to change settings on the trajectory generator like the ‘Max Speed’ or responsiveness values. The relevant settings are exposed to blueprint and can easily be changed at runtime as follows.
This example is shows a simple input based hold for walk and release for run. When walking the max speed is reduced to 200 and when running it is reset again to 400.
Trajectory Replication
The very first step of replicating motion matching is to replicate the input vector to the trajectory generator as this is the primary input into the motion matching system. In short this is the order of things:
Controlling Client Predictively Sets the Trajectory Input Vector
The input vector is then sent to the server
The server multi-casts the input vector to all clients where the input vector is set. In the case of the controlling client, the input vector does not need to be set as it was already predicted. Some validation may be preferential. here.