Simplify Testing

In this lecture we are testing our game and need to hit the bricks…which is tedious. The video suggests moving blocks around and creating new blocks…which works, but I didn’t want to change my game.

Instead, I duplicated the top wall object and created a bottom wall object above the lose collider. Now I can launch the ball and let the game test itself :slight_smile:

Passing along in case other students might like this suggestion

Cheers,
James

I changed the line in Ball.cs that adds a force to the ball to read “new Vector2(0f, 10f)”. That way you can position a 3 hit brick directly above the paddle and let the ball fly straight up a down.

1 Like

I actually test it without changing any code.
Just click play and then pause. Then increase the paddle scale (x axis) so it covers the entire screen.
That way, once the play test is over, everything returns to normal without needing to worry about reverting temporary changes…

1 Like

I also did this, but I made public variables for the x force and y force so that I can adjust them form the editor.
I have modified the code to only have the relevant code to this reply.

public class Ball : MonoBehaviour {

    public float ballHForce = 2f;
    public float ballVForce = 10f;

    // Update is called once per frame
    void Update () {
        if (!hasStarted) {
            if (Input.GetMouseButtonDown(0)) {
                this.GetComponent<Rigidbody2D>().velocity = new Vector2 (ballHForce, ballVForce);
            }
        }

    }
}

The assignment values to ballHforce and ballVForce are so they have a default value in case the game designer doesn’t input anything.

A simpler way on how I did it was to start and pause the game, stretch my paddle to cover the entire game and unpause, that way the ball will always bounce back and when I stop the game the paddle itself is still it’s normal size.

Privacy & Terms