Obstacle Avoidance
The above video shows off the basic functionality of a simple obstacle avoidance program I created in Unity2D. I had the player unit follow a simple code where it would just move in a straight line towards wherever the user clicked on the screen. To avoid the obstacles, I used Unity's built-in raycasting functionality. Three rays were cast out in front of the unit, each one represented by the yellow lines in the scene. Whenever one of these rays hit another object, it sent the data of the point to the movement code, where it temporarily assigned a new movement target to the unit, calculated by the obstacle's collision point and normal vector. Once the unit had reached the new target location, it would again attempt to move towards the mouse click position and repeat the process until the obstacle had been cleared.