void Cheat() { if (hasStarted == true & ability > 0) { // Bounce the ball toward to the paddle. if (Input.GetMouseButtonDown(0)) { Debug.Log("Ball bounce back to paddle."); paddleToBallVector = paddle.transform.position - this.transform.position; bounceBackVector = new Vector2(paddleToBallVector.x, paddleToBallVector.y); this.GetComponent <Rigidbody2D> ().velocity = bounceBackVector.normalized * speedModifier; ability--; power.PowerPullCount(); // Reset the ball to the paddle. // Noticed BUG : Reset after bounce will cause ball lock under the paddle out of the view port. } //else if (Input.GetMouseButtonDown (2)) { // this.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0,0); // Debug.Log ("ballToPaddleStart is " + ballToPaddleStart); // hasStarted = false; // Debug.Log ("Player is a shamless pig."); //this.transform.position =new Vector3 (4f ,0.56f ,0f ); // } } }
void OnCollisionExit2D(Collision2D Ball) { if (isBreakable) { AudioSource.PlayClipAtPoint(crack, transform.position, 2f); HandleHits(); } else if (isPower) { ball.ability++; powerPull.PowerPullCount(); AudioSource.PlayClipAtPoint(powerUp, transform.position, 2f); } }