Implementing the A* algorithm
First, we implement the basic classes that we introduced before, such as the Node class, the GridManager class, and the PriorityQueue class. Then, we use them in the main AStar class.
Node
The Node class represents each tile object in the 2D grid. Its code is shown in the Node.cs file:
using UnityEngine;
using System;
public class Node {
    public float costSoFar;
    public float fScore;
    public bool isObstacle;
    public Node parent;
    public Vector3 position;
   Â
    public Node(Vector3 pos) {
        fScore = 0.0f;
        costSoFar = 0.0f;
        isObstacle = false;
        parent = null;
        ...