How to implement step movement in 2D

Hi everyone. Im currently creating a grid based game but I’m having difficulty implementing the step based movement. I want the character to move a certain amount of space when each arrow is pressed respectively. I’m currently using transform.position but this overlooks the collisions with the boundaries set in place.

Any help or advice will be greatly appreciated.

If you have a collider and a rigidbody on the character, using rigidbody.MovePosition will move the object just like setting the transform’s position, but it will respect colliders, and not move through them.

If you don’t have a rigidbody (you probably don’t need physics on the character if you’re using a grid), you should either raycast to where the player’s trying to go, and stop the movement if the raycast hits something, or store the data about where the character can and cannot go somewhere.