public void SpawnTheBall(Vector2 directionOfPointer, float torque, float force) { ball = BallList[ChooseThisColor.chosenColorNumber]; if (ball != null) { if (playerStats.currentNumberOfBalls > 0) { Vector2 ballDirection = directionOfPointer - new Vector2(this.transform.position.x, this.transform.position.y); Quaternion rotation = Quaternion.LookRotation(Vector3.forward, ballDirection); Rigidbody2D rb = ball.GetComponent <Rigidbody2D>(); moveDirection = ballDirection; spin = torque; power = force; ball.transform.rotation = rotation; ball.transform.position = this.transform.position; Instantiate(ball); playerStats.UseBalls(1); ball.gameObject.GetComponent <BallMotor>().AddForceAndTorque(ballDirection, torque, force); rb.AddForce(ballDirection * force * 1000); ball.GetComponent <Rigidbody2D>().AddTorque(torque, ForceMode2D.Impulse); } } bc.UpdateBallCount(); }
public void GetMoreBalls() { playerStats.gameOverUI.SetActive(false); playerStats.gamePausedUI.SetActive(false); Time.timeScale = 1; playerStats.addBalls(); bc.UpdateBallCount(); }