How to detect if the player is not moving for specific duration of time

I want my character to do some animation if it stopped moving for 30s

You should give more details here. Anybody who tried to help you here has to guess at how you are moving your character. I’ll guess that he is moved with a rigidbody, so a check to see if velocity is equal to zero can start a timer if true and once 30 seconds is reached, do the animation:

bool timerStarted = false;
float timer = 0.0f;

void Update()
{

if(rigidbody.velocity == Vector3.zero)
{
if(!timerStarted)
{
timerStarted = true;
timer = 0.0f;
}
else
{
timer += Time.deltaTime;
}
if(timer >= 30.0f)
{
anim.SetTrigger(“doALittleDance”);
timerStarted = false;
timer = 0.0f;
}
}
else
{
timerStarted = false;
}
}

That’s a bit of untested code, but it should do the trick in the rigidbody case.