if there is no obstacle closestobject will return null. I should remove all else's and leave return targetPoint at the end though