Suggestion: Set Ball's X Velocity to 0 for playtesting

Another idea on playtesting your hit count/sprite swapping. We gave the Ball object an X velocity - to cause it to come off the paddle at an angle. To quickly test that Brick.cs is counting hits and swapping sprites correctly:

  1. In Brick.cs, make xVelocity a public variable so you can adjust it in the Inspector
  2. Set a 2-hit brick directly over the paddle
  3. Set xVelocity to 0
  4. Play your scene and don’t move the paddle

Or publicly expose some variables for the two floats like so:

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.

Privacy & Terms