Using Splines to drive Motion Matching
It is also possible to drive Motion Matching using splines. This method allows you to create more complex and dynamic paths for your characters to follow. The SplineCharacterController
script is provided to help you achieve this.
Example
To explore an example scene, access the Package Manager, select the Motion Matching package, and import the Examples sample. The sample scene will be located at Samples/Motion Matching/[version]/Examples/Scenes/00_Basic/ExampleSplines.unity
.
Getting Started:
- Add the
SplineCharacterController
script to a GameObject. -
Create a spline using the
Spline
component. Visit the Spline documentation for more information.Tip
Splines can be modified at runtime to create dynamic paths for your characters to follow.
-
Assign the spline to the
SplineCharacterController
script. - Assign a
MotionMatchingController
to theSplineCharacterController
script. - Control the character's velocity by setting the
Speed
property of theSplineCharacterController
script.
Note
Feel free to modify the SplineCharacterController
script to suit your needs. For example, you can add a method to set the character's speed based on the distance to the next waypoint.