code for detecting if a 2d infinite runner player stopped moving because it hit a wall or something

hello, I have a 2d infinite runner kit that I need a code to detect if the player stops running or not moving due to blockage of a wall or any other stuff that the player renders unable to get more distance. I want this to be detected since I have created a background that I want it to stop its scroll animation if the players stops moving, because it looks weird when the player stops getting distance but the scroll animation of the background still moves. I know already how to stop it… just don’t know how to create an if statement.

You can check his velocity to know that it is not moving: if GetComponent<RigidBody2d>().velocity.x (y, z) is 0 that means your player is not moving.
To make sure he stopped because of a wall / obstacle you can do a short raycast in front of the player and see if you hit something.