So this is the logic :
//here we click the mouse we launch the ball
and then change now the hasStarted to true so the If statement is locked and cant be executed again.
hasStarted = true; // but its not working.
void Update()
{
if (hasStarted == false) // 1)If hasStarted == false then execute the if statemen
{
LockBallToPaddle(); // 2) we lock the ball
LaunchOnMouseClick(); // 3) We press the MouseButton and the ball launches
hasStarted = true; // 4) We change the bool so dont execute again the if statement
again(BUT its not working)
}
}
private void LaunchOnMouseClick()
{
if (Input.GetMouseButtonDown(0))
{
// hasStarted = true; //<---- working like in the course
GetComponent<Rigidbody2D>().velocity = new Vector2(xPush, yPush);
// hasStarted = true; <---- if i put here is still working and it changes after we launch the ball.Why is working here and in Update NO????? it still executes after the ball was launched.
}
}