Node

The Node class will handle each tile object in our 2D grid and will be, used to represent the maps shown in the Node.cs file:

using UnityEngine; 
using System.Collections; 
using System; 
 
public class Node : IComparable { 
  public float nodeTotalCost; 
  public float estimatedCost; 
  public bool bObstacle; 
  public Node parent; 
  public Vector3 position; 
 
  public Node() { 
    this.estimatedCost = 0.0f; 
    this.nodeTotalCost = 1.0f; 
    this.bObstacle = false; 
    this.parent = null; 
  } 
 
  public Node(Vector3 pos) { 
    this.estimatedCost = 0.0f; 
    this.nodeTotalCost = 1.0f; 
    this.bObstacle = false; 
    this.parent = null; 
    this.position = pos; 
  } 
 
  public void MarkAsObstacle() { 
    this.bObstacle = true; 
  } 

The Node class stores properties such as the cost from the starting point and the ...

Get Unity Artificial Intelligence Programming - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.