〰️MPath
Last updated
Last updated
MPath Component is the bridge between the Path Constrain and any Path/Spline solution you may use. It will take the values needed from a spline and it will translate them to constraint the character so it follows and stays on the path.
The MPath will use any type of IPath component to get the spline/path values. If an animal using a Path Constraint component enters the Colliders Bound of this component then the search for the closest point on the spline will start. if both search radius (MPath and Path Constraint ) are near, and Automatic is set to true then the character will be constrained to the Path.
Any type of collider set as a trigger. (Box Collider Recommended)
Any type of IPath Component (Path Link (Straight), Path Link Cinemachine, Path Creator)
Type of Path solution to use, you can use any of the 3 solutions included (Path Link (Straight), Path Link Cinemachine, Path Creator)
Add your solution to the path and then hit the refresh button.
The character will be constrained to the path as soon as both Search Radius instersect
Some paths are set to not be Automatic. To activate the, go to the Path Constraint component, add an Input connection, and use the method TryEnterExitPath().
This also works for exiting a path in the middle of it.
This allows to change automatically to a new path when the character is already in another path. The new path needs to be set to automatic also.
The character cannot rotate or change direction while on the path. (The character can walk backward)
When lock rotation is true you can set the follow direction on the Path, this will automatically rotate the character to match the correct orientation during the path.
None: the Character will keep the starting path orientation when entering from the start or the end of the spline
Entering from End | Entering from Start |
---|---|
Forward: The Character will be oriented to the Forward Path orientation (Start to End)
Entering from End | Entering from Start |
---|---|
Backward: The Character will be oriented to the Backward Path orientation (End to Start)
Entering from End | Entering from Start |
---|---|
The Character will follow also the Path rotation values
Applies an offset to the Character during the Path Constraint
Use this Transform to have a gameobject follow the current position of the Character on the Path
The Character can exit automatically if it reaches the Start of the Spline
The Character can exit automatically if it reaches the Start of the Spline
The Character can exit automatically if a state interrupts the spline constraint. (E.g. Jumping on the middle of the spline)
When the character is inside the Path bounds then a search will start to find if the character can be constrained when the search radius intersects. The interval is the time to execute this search. increase this value to increase performance. Reduce it to increase precision.
Interval = 0.5f | Interval =0f |
---|---|
Once the character activates the path constraint, this time will need to elapse in order to exit the path again. This is useful to avoid entering and exiting the path in the same frame.
Radius to search a nearby Path Constraint component. When the Path Constraint sphere trigger and the Path sphere triggers intersect. It means the Character can activate a path.
An offset of the Radius value relative to the Path position.
Collider assigned to the Path. This allows us to calculate searching for a character only when a character is inside the trigger.
Filter what Layer can be used on the Paths (Animal Layer is the Default).
What state to activate when entering the path
When is active the Animal cannot move on the Y-Axis while is on the path. Disable this if you want to Jump while on the path.
(img)
Ignore grounded can be used when there is no terrain or ground beneath the path..
(img)
Disable States on the Character while is on the path. E.g. while on the path you can disable the Jump State.
(img)
States that will force an early exit on the path. E.g. Jump can force exiting the path if the Jump State is on this list.
(img)
If enable, playing any mode will exit the path
Modes that will force an early exit on the path. E.g. Damage can force exiting the path if the Damage Mode is on this list.
(img)
...
...