Difference between revisions of "PathEnemyFSM"

From Headbone Creative
Jump to: navigation, search
(Updating API info)
(Updating API info)
Line 6: Line 6:
 
=== playerTag : string ===
 
=== 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.  
 
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; ===
+
=== path: Transform[] ===
 
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.  
 
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>
 +
/// Path enemy loop style.
 +
/// </summary>
 +
public enum PathEnemyLoopStyle {
 +
None,
 +
Loop,
 +
PingPong,
 +
};
 +
 +
/// <summary>
 +
/// The setting for how to loop
 +
/// </summary>
 +
public PathEnemyLoopStyle howToLoop = PathEnemyLoopStyle.Loop;
 +
 +
/// <summary>
 +
/// Path enemy path direction.
 +
/// </summary>
 +
public enum PathEnemyPathDirection {
 +
None,
 +
Forward,
 +
Backward,
 +
};
 +
 +
/// <summary>
 +
/// The current direction.
 +
/// </summary>
 +
public PathEnemyPathDirection currentDirection = PathEnemyPathDirection.Forward;
 +
 
/// <summary>
 
/// <summary>
 
/// The path.
 
/// The path.

Revision as of 18:41, 16 April 2013

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[]

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> /// Path enemy loop style. /// </summary> public enum PathEnemyLoopStyle { None, Loop, PingPong, };

/// <summary> /// The setting for how to loop /// </summary> public PathEnemyLoopStyle howToLoop = PathEnemyLoopStyle.Loop;

/// <summary> /// Path enemy path direction. /// </summary> public enum PathEnemyPathDirection { None, Forward, Backward, };

/// <summary> /// The current direction. /// </summary> public PathEnemyPathDirection currentDirection = PathEnemyPathDirection.Forward;

/// <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;

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox