Most classical guitarists learned to play multi-part music nearly at the beginning of their studies. Arpeggio studies by Carulli, then Carcassi, Sor, Aguado, then works by Brouwer, Villa-Lobos, et al. This music all expects students to be able to do (at least) two things at once. Imagine for a moment a world in which guitar students spend significant time working on playing only melodies, like, say, singers or violinists or flutists. They'd have so much more clarity about what a melody should sound like: legato, but with articulation inflections that convey meaning, dynamic shaping, timbral coloration, rubato. Their melodic phrases would have time to mature into full-fledged, universally comprehensible musical gestures.
Instead, we are compelled forward into melody with accompaniment, and hard on its heels, counterpoint. It's no wonder, then, that so many players don't realize their melodic playing is often hampered by their accompaniments. We hear it in the absence of meaningful articulations and dynamics. But it is most vivid in the melody's frequent loss of rhythmic clarity or metric sense.
Think of rolling: most guitarists think nothing of rolling chords, doing it for most if not all chords, even including double-stops, or two-note chords (I'll talk more about rolling chords in another post). Every time a chord is rolled, there is a rhythmic displacement of notes. In inexperienced hands, this displacement happens too often to the melody note.
Think of shifting: when we shift our left hand, there is a tendency to lose time. Shifts occur constantly, causing repeated rhythmic bumps in the tune.
Think of shape changes: when our left hand has to assume a new, awkward shape we often lose time. The melody gets delayed.
Think of slurs: how many players struggle to play slurs in time? They always (always) come out too soon. This is yet another insult to the melodic rhythm.
Each of these and many other circumstances can cause interruptions in the melodic rhythm if special care isn't taken.
Obviously, each is an expression of a different technical issue and in many cases, there are additional piece-specific challenges along the same lines. It is easy to think that, as you get "better" you'll resolve each of these issues in turn, but in the meantime, your piece suffers and you get used to hearing the melody subtly distorted.
The fastest way to correct this problem is to simply play the melody by itself. It is so obvious and simple and yet, it's remarkable how few do this regularly. Play it in a fingering that accommodates it readily, unrelated to the fingering required when playing the full texture. Play it musically, with full-bore commitment to its metric sense, it's rhythmic character, it's style. Use dynamics, timbral subtlety, variety of articulation. Make it come to life.
As you learn to REALLY play the melody, listen to it closely. Internalize it's natural flow. Get better acquainted with how it should sound. With it's rhythm.
Then, put the accompaniment back in. It is MUCH easier to play the melody correctly after doing that kind of prep-work. It will be so well "in your ear" that you'll easily notice if you distort it. Especially if you tape yourself.
Nothing will reveal this type of problem to you more quickly or easily than recording yourself. Many people now have this capability right on their phones--in other words, why not? When you listen to yourself objectively, listen for rhythm. Work to get it to sound the way it "wants" to sound, according to your work on it alone. This will work wonders, especially if you are truly critical of your playing as you listen back.
I like to imagine my melodies played by other instruments. What if a clarinetist were playing this line? How would a cellist handle this phrase? What would a singer do with this passage? If you really imagine it hard, you can learn much. We guitarists need to take a cue from those who play only one note at a time. If we do, our pieces will sound better.
Here's a vote for playing melodies with good rhythm. How do yours sound?