Try $f(x,y)=x^2+y^2$, $f \colon \mathbb{R}^2 \to \mathbb{R}$. If you want connected constant dimensional fibers, try $f(x,y,z)=z$ on the cylinder with one point deleted $X=\{(x,y,z)|x^2+y^2=1\}-\{(1,0,0)\}$. For a more natural example, take the map $f(x,y)=y^3-p-qx-rx^2-x^3$ for suitable constants $p, q, r$, so that you get a family of cubic curves, and arrange that the curve $f^{-1}(0)$ is a cusp, while $f^{-1}(\varepsilon)$ has two components for $\varepsilon > 0$. Then you really see jumping of fundamental group. But I still don't have a nice example with all fibers compact.