〰️MPath

Overview

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.

How it works

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.

Requirements

Parameters

Path

IPath

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.

Automatic

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.

AutoChangePath

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.

Lock Rotation

The character cannot rotate or change direction while on the path. (The character can walk backward)

Follow Direction (Lock Rotation = True)

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 EndEntering from Start
  • Forward: The Character will be oriented to the Forward Path orientation (Start to End)

Entering from EndEntering from Start
  • Backward: The Character will be oriented to the Backward Path orientation (End to Start)

Entering from EndEntering from Start

Use Path Rotation

The Character will follow also the Path rotation values

Alignment Offset

Applies an offset to the Character during the Path Constraint

Path Position

Use this Transform to have a gameobject follow the current position of the Character on the Path

Can Exit on Start

The Character can exit automatically if it reaches the Start of the Spline

Can Exit on End

The Character can exit automatically if it reaches the Start of the Spline

Can Exit on Middle

The Character can exit automatically if a state interrupts the spline constraint. (E.g. Jumping on the middle of the spline)

Interval

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.5fInterval =0f

Path Cooldown

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.

Search Radius

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.

Search Offset

An offset of the Radius value relative to the Path position.

Path Bounds

Collider assigned to the Path. This allows us to calculate searching for a character only when a character is inside the trigger.

Layer

Filter what Layer can be used on the Paths (Animal Layer is the Default).

Animal

Activate State

What state to activate when entering the path

Ignore Vertical

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

Ignore grounded can be used when there is no terrain or ground beneath the path..

(img)

Disable States

Disable States on the Character while is on the path. E.g. while on the path you can disable the Jump State.

(img)

Ignore States

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)

Exit Any Mode

If enable, playing any mode will exit the path

Ignore Modes

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)

Reactions

...

Events

...

Last updated