Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1") && ballInPlay == false)
        {
            transform.parent = null;
            ballInPlay       = true;
            rb.isKinematic   = false;
            rb.AddForce(new Vector3(ballInitialVelocity, ballInitialVelocity, 0));
        }

        if (transform.position.y < bottomY)
        {
            Destroy(this.gameObject);
            BrickBreaker bbScript = Camera.main.GetComponent <BrickBreaker>();
            bbScript.BallDestroyed();
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        //if the ball goes below the paddle destroy ball GameObject
        if (transform.position.y < bottomY)
        {
            Destroy(this.gameObject);
            BrickBreaker.lives -= 1;
            BrickBreaker bbScript = Camera.main.GetComponent <BrickBreaker>();
            bbScript.BallDestroyed();
        }

        if (Input.GetKey(KeyCode.Space))
        {
            startText.gameObject.SetActive(false);
            GetComponent <Rigidbody2D>().AddForce(new Vector2(x, 0.5f) * Time.deltaTime * force);
        }
    }