internal GameController controller;
[SerializeField] private float shotForce;
+
+ public Rigidbody2D Rigidbody => _rigidbody != null ? _rigidbody : _rigidbody = GetComponent<Rigidbody2D>();
+ private Rigidbody2D _rigidbody;
private void OnCollisionEnter2D(Collision2D other)
{
controller.BallDropped();
}
- public void Shoot(Transform playerTransform)
+ public void Shoot(Vector3 target, float time)
{
- transform.right = (controller.PlayerHoop.transform.position - transform.position);
- var rigidbody = GetComponent<Rigidbody2D>();
- rigidbody.velocity = Vector2.zero;
- rigidbody.AddForce(transform.right * shotForce);
+ transform.right = target - transform.position;
+ Rigidbody.velocity = Vector2.zero;
+ Rigidbody.AddForce((transform.right + (transform.up * 0.5f)) * (shotForce * ((Mathf.Clamp(time, 0f, 1f) + 1))));
}
}
}