You should try to search A* on Google. That's a good algorithm to get the path between 2 point. I don't know what kind of game are you doing but it work for both rts and platform games.