private void move() { if (Input.GetKey(KeyCode.LeftArrow)) { movementScript.left(speed); } if (Input.GetKey(KeyCode.RightArrow)) { movementScript.right(speed); } }
private void move() { float xDistanceToBall = ball.position.x - transform.position.x; if (Mathf.Abs(xDistanceToBall) < MIN_BALL_DISTANCE_THRESHOLD) { return; } if (xDistanceToBall > 0) { paddleMovementScript.right(speed); } else { paddleMovementScript.left(speed); } }