Movement in RAIN{one}

Movement in RAIN{one} is usually accomplished in one of two ways: directly through code with a SimpleMind or automatically with a BehaviorTreeMind. The Move node is a primitive action that directs the AI to move toward a target.

Regardless which Mind type is chosen, RAIN{one} relies on a path manager to accomplish movement; either a RAINPathManager or a custom one defined by the user.

RAIN Path Manager

RAIN{one} automatically adds a RAINPathManager to your GameObject when you create an AI through the RAIN{one} menu. The RAINPathManager is used by the BehaviorTreeMind and the SimpleMind to move your AI through the world. It has a number of parameters to customize your movement, supports simple obstacle avoidance, and can be further enhanced by using waypoint collections, navigation grids, or custom waypoint graphs.

Obstacle Avoidance

When enabled, the RAINPathManager will attempt to avoid obstacles in addition to following its current path. The obstacle avoidance algorithm continuously predicts future collisions and always attempts to avoid the collision that will happen next (soonest in time) by adding forces perpendicular to the collision point. Although obstacle avoidance works well in certain situations, it may have trouble in large crowds or in areas with many static objects. In these cases, you may consider turning obstacle avoidance off and use other means to avoid moving objects.

Direct Movement

If the path manager isn't set up to use a waypoint collection, navigation grid, or custom path graph, it will attempt to move directly toward its target. This is generally acceptable for simple animations or follow behaviors.

Waypoint Collections

A Waypoint Collection is simply an empty GameObject used to contain waypoints. Once populated with waypoints, the RAINPathManager can use the collection to help navigate the world. To learn more, read Movement Using Waypoints.

Navigation Grid

A navigation grid is a collection of connected, rectangular regions that define a walkable area. In RAIN{one}, navigation grids are generated by using a Recast Generator For more information on how to use navigation grids, read Movement Using a Navigation Grid.

Custom Path Graph

Custom path graphs may be attached to the PathManager at runtime through the RAIN{one} API. RAIN{one} supports graph sharing between AI. Checking the Use Custom Waypoint Graph option and setting a Custom Graph Name will direct the AI to attempt to use the shared graph of the given name.

Custom Path Manager

You can define your own custom path manager by extending the PathManager abstract class in RAIN{one}.

Executing Movement

As stated above, movement can be executed in code or in a behavior tree. Both approaches make use of the path manager.

In code, the PathManager supports these calls: Move() - Directs the AI to move toward the MoveTarget defined in the PathManager for one timestep. MoveTo(Vector3) - Directs the AI to move toward the given point for one timestep.

In each case, the AI will rotate to face its forward movement direction unless a separate LookTarget has been specified. When a LookTarget is specified, you must also call the corresponding Look method: Look() - Directs the AI to rotate toward the LookTarget defined in the PathManager for one timestep. LookAt(Vector3) - Directs the AI to rotate toward the given point for one timestep.

When using Behavior Trees in RAIN{one}, movement typically occurs by adding Move action nodes to the behavior tree. When these nodes are used, direct calls to the Move and Look methods are not required from code.

For more information on movement, see

See Also

movement/start.txt · Last modified: 2023/01/22 11:03 (external edit)