4. Given the function $f(x)=\sin \frac{\pi}{2} x$, for any $t \in \mathbf{R}$, denote the maximum value of the function $f(x)$ on the interval $[t, t+1]$ as $M_{t}$, the minimum value as $m_{t}$, and $h(t)=M_{t}-m_{t}$. Then the range of the function $h(t)$ is $\qquad$
4. $\left[1-\frac{\sqrt{2}}{2}, \sqrt{2}\right]$.

Notice that, for $k \in \mathbf{Z}$, $h(t)$ is given by
$$
=\left\{\begin{array}{ll}
\sin \frac{\pi}{2}(t+1)-\sin \frac{\pi}{2} t, & t \in[2 k-1,2 k] ; \\
1-\sin \frac{\pi}{2} t, & t \in\left[2 k, 2 k+\frac{1}{2}\right] ; \\
1-\sin \frac{\pi}{2}(t+1), & t \in\left[2 k+\frac{1}{2}, 2 k+1\right] .
\end{array}\right.
$$

By combining the graphical and numerical analysis, we know that
when $t=2 k-\frac{1}{2}(k \in \mathbf{Z})$, $h(t)_{\text {max }}=\sqrt{2}$;
when $t=2 k+\frac{1}{2}(k \in \mathbf{Z})$, $h(t)_{\text {min }}=1-\frac{\sqrt{2}}{2}$.
Therefore, the range of the function $h(t)$ is $\left[1-\frac{\sqrt{2}}{2}, \sqrt{2}\right]$.