7 [RequireComponent(typeof(Rigidbody2D))]
8 [RequireComponent(typeof(CircleCollider2D))]
9 public class Ball : MonoBehaviour
11 internal GameController controller;
13 [SerializeField] private float shotForce;
15 public Rigidbody2D Rigidbody => _rigidbody != null ? _rigidbody : _rigidbody = GetComponent<Rigidbody2D>();
16 private Rigidbody2D _rigidbody;
18 private void OnCollisionEnter2D(Collision2D other)
20 controller.BallDropped();
23 public void Shoot(Vector3 target)
25 transform.right = target - transform.position;
26 Rigidbody.velocity = Vector2.zero;
27 Rigidbody.AddForce((transform.right + (transform.up * 0.5f)) * shotForce);