Ejemplo n.º 1
0
        /// <summary>
        /// Called by Unity.
        /// Can be overriden but be sure to call base.Start() to allow the agent to initialize properly.
        /// </summary>
        public virtual void Start()
        {
            if (searchGrid == null)
            {
                // Try to access a default grid
                searchGrid = AStarGridManager.DefaultGrid;

                // Check for error
                if (searchGrid == null)
                {
                    // Print a warning
                    Debug.LogWarning(string.Format("Agent [{0}]: The are no AStar Grids in the scene. Pathfinding is not possible", gameObject.name));
                }
            }
        }
Ejemplo n.º 2
0
        // Methods
        /// <summary>
        /// Called by Unity.
        /// </summary>
        public virtual void Start()
        {
            // CHeck if we have a grid
            if (searchGrid == null)
            {
                // Try to access a default grid
                searchGrid = AStarGridManager.DefaultGrid;

                // Check for error
                if (searchGrid == null)
                {
                    // Print a warning
                    Debug.LogWarning(string.Format("Agent [{0}]: The are no AStar Grids in the scene. Pathfinding is not possible", gameObject.name));
                }
            }


            // Try to get a collider
            colliderObstacle = GetComponent <Collider2D>();

            // Check for collider
            if (colliderObstacle == null)
            {
                Debug.LogWarningFormat("DynamicObstacle '{0}' does not have a Collider2D attached!", gameObject.name);
            }

            lastPosition = transform.position;
            lastRotation = transform.eulerAngles;
            lastScale    = transform.localScale;

            // Register obstacle
            if (searchGrid != null && colliderObstacle != null)
            {
                searchGrid.registerObstacle(this);
            }

            // Trigger an update for the obstacle
            invalidate();
        }
Ejemplo n.º 3
0
 internal static void unregisterGrid(AStarGrid grid)
 {
     // Remove the grid from the list
     activeGrids.Remove(grid);
 }
Ejemplo n.º 4
0
 // Methods
 internal static void registerGrid(AStarGrid grid)
 {
     // Add the grid to the active grids
     activeGrids.Add(grid);
 }