Motivated by this question, I ask the question below.
Let $S\subset M$ be a closed in $M$ but not necessary compact, embedded submanifold of a complete Riemannian manifold $M.$ Assume that for each $p \in M$, there exist a unique closest point on $S$, i.e a unique point $\tilde s(p) \in S$ such that $d(p,\tilde s (p))=d_S(p)=d(p,S)$.
When $S$ is compact, we can show that the map $\tilde{s}:M\to S$ is continuous, as follows:
Let $\{p_n\}\to p$ in $M.$ So now $\{\tilde{s}(p_n)\}\in S$ is a sequence in $S.$ Take any subsequence of $\{\tilde{s}({p_n}_k)\}\in S,$ which by compactness of $S,$ has a convergent subsequence (we abuse notation and use the same indexing here) $\{\tilde{s}({p_n}_{k})\} \to s\in S.$ Now by continuity of distance $d(.,.)$ in both arguments, $d({p_n}_{k}, \tilde{s}({p_n}_{k}))\to d(p,s).$
Next, by continuity of $d(.,S), d({p_n}_{k},S)\to d(p,S).$
By the two arguments above, $d(p,s)=d(p,S).$ By uniqueness of the closest point and the definition of $\tilde{s}$, $s$ must be $\tilde{s}(p).$
This shows that any subsequence of $\{\tilde{s}(p_n)\}\in S$ has a convergent subsequence, converging to $\tilde{s}(p).$ This shows that the whole sequence $\{\tilde{s}(p_n)\}\to \tilde{s}(p), n\to \infty.$
Question I: Is my argument correct and complete?
Question II: Clearly the above argument uses the fact that $S$ is compact. So is $\tilde{s}$ discontinuous when $S$ is not compact? If so, what's an example?
Question III: Are there "nice cases" (necessary/sufficient condition on) for $S$ where the continuity is ensured?
EDIT (following the first comment):
Perhaps we can change the subsequence argument above to showing that if $s$ is an accumulation point of $\{\tilde{s}(p_n)\}\in S,$ then $s=\tilde{s}(p)$ is the only possibility. This shows that the set of accumulation point of $\{\tilde{s}(p_n)\}\subset S,$ if any, is unique. But how can we guarantee that there's at least one accumulation point?
EDIT (following the comment by Moishe Kohan):
We note that $d(p_n, \tilde{s}(p_n))=d(p_n,S) \le M \forall n \ge 1,$ while the last inequality is true since the sequence $\{p_n\}$ is bounded, being convergent. So $d(p_n, \tilde{s}(p_n)) \le M \forall n \ge 1.$ Now again, since the sequence $\{p_n\}$ is bounded, so is $\{\tilde{s}(p_n)\} \subset S$ and $S$ being closed, $\{\tilde{s}(p_n)\}$ has an accumulation point. And now the preceding argument shows that the accumulation point is unique, making the sequence convergent.