Can't move player with rigidbody.velocity

Hi all. I just started working on a 2D beat’em up. I started doing it with the 2D settings, but soon discovered that I would have to switch to 3D in order to be able to move the characters in depth too, like in the classic beat’em ups, not just from right to left. All the graphics are going to be 2D anyway.

So I’m struggling now to make the player move. I’ve set up a plane object, and the character object has a rigidbody and a box collider. So, to make the character move, I’m doing something like this:

xSpeed = horizontalMove * speedIncrease;
		
rigidbody.velocity = new Vector3 (xSpeed, 0, 0);

What am I doing wrong?

Thanks in advance

Note in the documentation for rigidbody.velocity:

In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour.

Therefore, use rigidbody.AddForce(Vector3, Forcemode)

rigidbody.AddForce(new Vector3(xSpeed, 0, 0), ForceMode.VelocityChange);

There are 4 different Force Modes that create different results when adding force. Read the documentation about Force Mode here. I would try each of them out to choose which mode has the best effect for your current situation.