"A* pathfinding" is the alrogrithm you are looking for. Go to Youtube and you will find tons of tutorials about it.
Basic idea behind is that you need to create a grid of your game, and then take the point you are on and compare G force and F force for every square around you, by finding the lowest number, it will be your next fastest point, then on the next point you will do the samething until you get to the spot you are looking to get to; However, you need to consider the obstacles you may find on the way.