How to detect movement?

How could I detect movement or the absence of it? I tried with

if (Mathf.Floor(Mathf.Abs(rigidbody2D.velocity.y)) == 0) and with

if (rigidbody2D.velocity.y == 0)

and in both cases the if clause functioned when the real velocity was negative, I want tha some code happens when the gameobject is completely stopped.

Whenever comparing floats, you always want to use an epsilon. The easiest solution is like this:

if(Mathf.Abs(rigidbody2D.velocity.y) < 0.001)