Well, I actually tried understanding your problem, but I failed.
#1 You want to have an entity, that always faces the sphere.
#2 You solved that, by using vec_to_angle.
#3 If the sphere comes close to a certain distance to the entity your algorithm quits working for whatever reasons.
Did I get your point? Can you post the code you wrote?