I’m really sorry it took so long. Good news is I found the issue.
First of all, I’ll tell you how I found the bug so you can do this on your own with your future projects, then I’ll copy-paste the changes you need to do to your code.
How I found it.
Time.timeScale is a global thing, so it should affect everything but it wasn’t. First I printed the timeScale on the paddle’s script update, I immediately noticed that something was wrong, the timeScale always printed 1 regardless of the pause menu, so I assumed there was something modifying the timeScale, the issue with this is, the bigger the project, the harder it is to find which script is making changes, but there’s a neat trick for this; if you are using Visual Studio you can select a word and then press ctrl+shift+f in your keyboard, this will open a search bar with several options, search in the entire solution (the whole project) and there it was, your GameSession script was modifying the timeScale during Update, next thing to do is to simply prevent this from happening.
The solution is not that simple tho, there are some issues with controls and timeScale, if you simply erase that Update method in your GameSession script you’ll notice that your paddle will still move, that’s because how the script is written, it will always move, you’ll also notice that if you press the right mouse button the ball won’t move but it will be launched, quite annoying if you ask me. You could take this as a challenge and try to solve it on your own since I already gave you all the info you need, so, if you want, stop reading here and try to solve it on your own, if you are already tired of this copy-paste the next blocks of code.
GameSession script
void Update()
{
if (PauseMenu.GameIsPaused) { return; } //Add this line.
Time.timeScale = gameSpeed;
}
Paddle script.
void Update()
{
if (PauseMenu.GameIsPaused) { return; } //Add this line
Vector2 paddlePos = new Vector2(transform.position.x, transform.position.y);
paddlePos.x = Mathf.Clamp(GetXPos(), minX, maxX);
transform.position = paddlePos;
}
Ball script
private void LaunchOnMouseClick()
{
//Add the second condition to this "if" statement.
if (Input.GetMouseButtonDown(0) && !PauseMenu.GameIsPaused)
{
hasStarted = true;
myRigidbody2D.velocity = new Vector2(xPush, yPush);
}
}
I did not erase the constant speed update in the GameSession script because you might need it later on and you are already using a static variable so why not take advantage of it. Just don’t rely too much on Brackeys, his tutorials are good, but he tends to use really bad practices, like that static.
Hope this helps, and again, sorry it took so long.