Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using UnitySteer;
- /// <summary>
- /// Steers a vehicle to follow a path
- /// </summary>
- /// <remarks>
- /// Based on SteerToFollowPath.
- /// </remarks>
- [RequireComponent (typeof (Navigator))]
- public class SteerForAngryAntPath : SteerForPathSimplified
- {
- #region Private fields
- Path _angryAntPath;
- #endregion
- #region Public properties
- /// <summary>
- /// Path to follow
- /// </summary>
- public Path AngryAntPath {
- get {
- return this._angryAntPath;
- }
- }
- #endregion
- #region Path event handles
- void OnNewPath (Path path)
- // When pathfinding via Navigator.targetPosition
- {
- Debug.Log("PATH DONE " +Time.realtimeSinceStartup);
- Debug.Log ("Received new Path from " + path.StartNode + " to " + path.EndNode + ". Took " + path.SeekTime + " seconds.");
- _angryAntPath = path;
- var collect = new C5.ArrayList<Vector3>();
- foreach (var s in path.Segments)
- {
- collect.Add(s.To.Position);
- }
- collect.Add(path.EndPosition);
- Path = new Vector3Pathway(collect, 0.5f, false);
- }
- void OnTargetUnreachable ()
- // When pathfinding via Navigator.targetPosition
- {
- Debug.Log ("Could not pathfind to target position");
- _angryAntPath = null;
- Path = null;
- }
- void OnPathAvailable (Path path)
- // When pathfinding via Navigator.RequestPath (startPositio, endPosition)
- {
- Debug.Log ("Requested Path from " + path.StartNode + " to " + path.EndNode + " is now available. Took " + path.SeekTime + " seconds.");
- }
- void OnPathUnavailable ()
- // When pathfinding via Navigator.RequestPath (startPositio, endPosition)
- {
- Debug.Log ("The requested path could not be established.");
- }
- void OnPathInvalidated (Path path)
- // When a path requested by a Navigator on this GameObject is no longer valid - due to a connection or node disabling or removal
- {
- Debug.Log ("The path from " + path.StartNode + " to " + path.EndNode + " is no longer valid.");
- }
- void OnDrawGizmos()
- {
- if (_angryAntPath != null)
- {
- _angryAntPath.OnDrawGizmos();
- }
- }
- #endregion
- }
Add Comment
Please, Sign In to add comment