How to make objects flatten into and come out of floor?

Recently i was looking at the kingdom hearts games and noticed the enemies will flatten into the ground and come out of it again. An example can be found in this YouTube video at 1:20 in.

I’ve thought of scaling objects flat and having them scale up at a set rate or moving objects below the surface, indicating where they are with a decal, and then having them move above the surface. Effects and animations being used to help with the transitions. Out of these two ideas i like the second more. I figured there probably is a better way to do this though and could use some help.

Anything relevant would be helpful and appreciated be that examples, ideas, information, etc.
Thank you.

Here is another example.

210535-tumblr-md8hyovn7g1qbc2ylo2-500.gif