PathEnemyFSM
This script implements an AI that will follow a set path, unless the player comes to close. Once the player is close enough it will follow the player until the player is out of range, or until the maximum distance away from the path is reached (if useLeash is set to true).
Contents |
Public Variables
player : GameObject
This is the player object that the enemy will chase if it gets close enough.
playerTag : string
If the player object is not set when the scene starts, this script will attempt to find an object with this tag. If no object is found, an error is printed to the debug console.
path: Transform&91;&93;
This is the set of nodes that make up the path that will be followed. The enemy moves to the first node in this list before continuing along the path in the direction specified by the other variables below. /// <summary> /// The path. /// </summary> public ;
/// <summary> /// The chase start distance. /// </summary> public float chaseStartDistance = 1.0f;
/// <summary> /// The chase stop distance. /// </summary> public float chaseStopDistance = 2.0f;
/// <summary> /// The chase speed. /// </summary> public float chaseSpeed = 0.5f;
/// <summary> /// The rotate to path flag /// </summary> public bool rotateToPath = true;
/// <summary> /// The rotate speed. /// </summary> public float rotateSpeed = 5.0f;
/// <summary> /// The chase mode. (how to chase it) /// </summary> public PathEnemyChaseMode chaseMode = PathEnemyChaseMode.lerp;
/// <summary> /// The waypoint radius. /// </summary> public float waypointRadius = 0.1f;
/// <summary> /// The leash distance. /// </summary> public float leashDistance = 20.0f;
/// <summary> /// The use leash. /// </summary> public bool useLeash = true;
/// <summary> /// This flag indicates whether or not the scene is 2d or 3d. /// This affects how the rotation is calculated. /// </summary> public bool is2dScene = true;