Alright, after a bunch more testing it seems that clamping the angle where the barrels can rotate up and down messes up the raycast hitpoint for some reason???? I don't understand why it makes the X value stop changing as soon as it hit something that wasn't terrain but when I removed the clamp it became normal.