public void AddImpulseToBall(BaseBall ball) { deltaY = (ball.transform.position - transform.position).y * 2; Vector2 deltaV = Vector2.up * deltaY * speed * 1.5f; ball.AddVelocity(deltaV); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag(Definition.BALL)) { preHitObject?.Invoke(collision.gameObject); BaseBall ball = collision.gameObject.GetComponent <BaseBall>(); AddImpulseToBall(ball); } }