Thanks a lot.
I thought nobody was going to answer after some time. So I went ahead and converted a solution from pure C++ A pathfinding tutorial on youtube.
It made me understand how it works.
Though this will be useful for someone who stumbles upon this with the same issue.