How do i make an object move from one location to another while avoiding specified object?

I have an object and need to make it move to a another object at the end of the map while at the same time avoiding other object. This object would be like a wall. how would I make this object find its way to the other object?

Assuming you have a 3D scene and your obstacles are static (like walls and such) you can use Unity’s NavMesh. You can create areas that a target can move on and it will automatically mind a path to given destination while staying within its bounds. Ooo, I just found this too for obstacles using the NavMesh. That could be neat.


If you have a 2D scene instead, you could follow some basic A* pathfinding algorithms. There are a number of tutorials online explaining how to implement this algorithm.