Move player to specific location and avoid obstacle.


I need to move a player to many different location each time( the route not aligned), and avoid the obstacle.
i have try the code from this website :
Unity 3D - Enemy Obstacle Awareness - AI - Code Sample

but the player does not avoid obstacle and in some time go in another long route to arrive to the target.
should i use an algorithm for finding path?

Have you tried using NavMesh?

Assign the NavMesh Agent to your Character - then you have to bake the scene.
Check this link.

For your help, dodging the obstacles, try this,

Hope this helps.

In this Code last four if condition will remove.
Obstacle are remove it.