Rigidbody2d, velocity does not work as expected

Hello, im new in unity. So im still learning, im working right now on a 2D game. Im new to Rigidbody2D and velocity. So i just used it to make my player move. and this is the code for it:

rb.velocity = new Vector2(speed * Input.GetAxis(“Horizontal”) * Time.fixedDeltaTime, rb.velocity.y);

as i learned this code has to be in the FixedUpdate methode. to make the movement better. so everything is working as i learned. But i got a problem which is when i click on the console window while the game is on, and then back to the game window. Then my player does not move. Everything else work. Like when i press on the keyboard. (Right Arrow and left Arrow) the player does not move. but the flipX works well. so my player become unable to move. but when i press on space to make the player jump, then i can move as it should be. in the beginning i thought the problem was because the game goes to unfocus mode and then back to focus mode and that makes the fixedUpdate methode dont work. But then i realized that while im testing the level i have made, so i get the same problem. The player sometimes just doesnt move. like its stuck, and when i press on Left Arrow or Right Arrow the player flips. And when the player jumps, then the movement works again.
Please help guys im just stuck on it and i cant learn something new because of thinking about this issue.

( rb.velocity = new Vector2(speed * Input.GetAxis(“Horizontal”) * Time.fixedDeltaTime, rb.velocity.y):wink: TO MAKE THE PLAYER MOVE
(rb.velocity = new Vector2(0, jump):wink: to make the player JUMP.

The problem is not with my code. and i have tried everything, to figure out what the problem was. So finaly i got the problem. it was that my player goes to sleeping mode sometimes and that makes him not move when i press on the keyboard.

When Rigidbodies fall to rest - a box landing on the floor - they will start sleeping. Sleeping is an optimization which allows the Physics Engine to stop processing those rigidbodies. This way you can have huge amounts of rigidbodies in your scene as long as you make sure that they normally don’t move.

( Rigidbody sleeping happens completely automatically. Whenever a rigidbody is slower than the sleepAngularVelocity and sleepVelocity it will start falling asleep. After a few frames of resting it will then be set to sleep. When the body is sleeping, no collision detection or simulation will be performed anymore. This saves a lot of CPU cycles. )

but anyway thank you for your replay. thts means a lot.