You can use UnrotateVector with the forward vector of the ball and the world rotation of the ball to always bring back its direction of movement to the horizontal and vertical axis, then you can do the dot product with the joystick axis. Give it a try. Use plenty of Print String to verify that is working properly.