How do I move this rigidbody?

I have a rigidbody that needs to move with a keypress. I know how to do key input, velocity, forces, and translations, but I don’t know which one to use and how to use it. I tried using velocity, but I can’t figure out how to make it move diagonally. I tried translations, but that doesn’t work well with collisions, and I tried adding a force, but that makes the character keep on accelerating and it slides after the key isn’t pressed anymore. I think velocity is probably the answer, but as I said, the diagonal movement isn’t working.

Try Input.GetAxisRaw to stop the player on the spot and apply it to (“Horizontal”) and (“vertical”) in the input manager.

like

>     float hor = Input.GetAxisRaw ("Horizontal");
>     
>     float vert = Input.GetAxisRaw ("Vertical");

			rb.velocity = new Vector2 (hor * maxSpeed, vert * maxSpeed);