void Update() { if (Input.GetKeyDown(KeyCode.Space) && canShoot) { FindTheWayToGo.FindWay(ball.transform, transform); ball.GetComponent <Rigidbody2D>().velocity = new Vector3(FindTheWayToGo.wayY * 5f, FindTheWayToGo.wayX * 5f, 0); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.transform.tag == "Ball") { FindTheWayToGo.FindWay(ball.transform, transform); ball.GetComponent<Rigidbody2D>().velocity = new Vector3(FindTheWayToGo.wayY * 5f, FindTheWayToGo.wayX * 5f, 0); } }