2D Movement System (Stop Movement on Collision)

I’m trying to create a movement system for my maze game.

TLDR: Looking for a 2d movement system that infinitely moves the player in the chosen direction, and ceases movement on collision.

The player controls a square that moves infinitely up, down, left, or right when one of the arrow keys is pressed once, and only stops moving when the player’s 2d collider “collides” with another 2d collider (aka the maze walls). This then resets, allowing the player to make another move.

I’m very much a newbie to coding, and would much prefer working on puzzle designs and art (haha), so any help you can provide would be greatly appreciated.

For this case you could go for the MonoBehaviour method OnCollisionEnter2D in order to detect the square collision with the wall and change the player speed to 0 when that happens.