Created
March 15, 2022 01:46
-
-
Save wallstop/1513eb7679c7d45348bf917a407a76a5 to your computer and use it in GitHub Desktop.
PathNode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Pathfinding | |
{ | |
using UnityEngine; | |
public sealed class PathNode | |
{ | |
public readonly Vector3Int position; | |
public int gCost = int.MaxValue; | |
public int hCost = 0; | |
public int fCost = 0; | |
public PathNode parentNode = null; | |
public PathNode(Vector3Int position) | |
{ | |
this.position = position; | |
CalculateFCost(); | |
} | |
public void CalculateFCost() | |
{ | |
fCost = gCost + hCost; | |
} | |
public void Reset() | |
{ | |
gCost = int.MaxValue; | |
hCost = 0; | |
fCost = 0; | |
parentNode = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment