How to detect Object stuck in both wall?

I’m try to making ‘moving block’ in 2d platformer game.

I want to detect When an object(character) is pushed out by a ‘moving block’ and is trapped (or stuck) by a wall on the other side.

Is there any way other than checking if there is a collider by using raycast in both directions (ex: left and right) of the object every update()?

I’m not using rigidbody, and character object has Character Controller component. moving block is moving by change transform.posistion

This might work @chlgus1233
It gets the distance between 2 gameobjects. Maybe not be the best solution but it doesn’t need colliders or raycast to work. In this case it gets the distance from the player and the block you want to see if its stuck. Run in the Update() method

            var distanceBetween = Vector2.Distance(myPlayer.transfrom.position, blockToLookFor.transfrom.position);
            Debug.Log($"distanceBetween My Player and the stuck block is : {} == {distanceBetween}");