Restarting game doesn't make ball going(beginner)

I’m making breakout game, and i did simple lose, that shows lose text and button(restart game)
if(amountOfBalls < 1)
{
looseScreen.SetActive(true);
Time.timeScale = 0;
}

The problem is when i restart game(by this code*)

public void RestartGame()
    {
        Scene scene = SceneManager.GetActiveScene();
        SceneManager.LoadScene(scene.name);
    } *

My ball just spawns and don’t do anything, but when i loaded my game with unity, everything was working, if i lose and press button “replay” everything fine except the ball, it’s simply not going but i checked and don’t see any problems there, speed - fine, rigidBody - working, x and y - ok, timeScale = 1. Ball spawn by GameManager script, but other ball logic contains in the ball Script, here ball script:

public class ball : MonoBehaviour
{
    public float speed;

    protected Rigidbody2D rb;

    private void Start()
    {
        rb = GetComponent<Rigidbody2D>();

        AddStartingForce();
    }

    public void AddStartingForce()
    {
        float x = Random.value < 0.5f ? -1 : 1f;
        float y = Random.value < 0.5f ? 0.7f : 1.2f;

        rb.AddForce(new Vector2(x, y) * speed * Time.deltaTime);
    }
}

And here ball spawns by another script(GameManager):

private void Start()
    {
        Time.timeScale = 1;

        Instantiate(ball);
        amountOfBalls++;
    }

i’ll be really appreciate if you help me, please, ask questions if you need

Hi @Kar1s0n It is likely the issue revolves around where your code is calling the AddStartingForce method. You see, Rigidbody’s are a physics component, and as such, they require a little special handling. The FixedUpdate method is the update method where all physics changes must be handled. What I would try in order to solve this, I’d remove the AddStartingForce call from Start, then I’d set a private boolean in the ball class (let’s call it _StartForced) which begins with a false value. Then, I’d add a FixedUpdate method in ball. And in that method, I’d check to see if _StartForced is false. If it is false, then I’d add the starting force, and then set _StartForced to true.

This will make sure a start force is added only once, and within the fixed update method.

thank you, i won’t forget about physics and FixedUpdate !)