I can sing pretty much in tune a lot of melodies, but only when I play the same melody on guitar at the same time. When I hear the melody on a guitar I'm somehow able to follow it with my voice almost perfectly. However when I try to sing the same exact riff without support of guitar I can barely hit any notes. Does anyone had a similar experience and / or know how to overcome it ? Do you know if there are some specific excercise that address this problem ?
Yes, this is not uncommon. In voice lessons a teacher will frequently play a line in parallel with the student singing. The purpose is to help you hear it. Eventually every singer needs to be able to hear the line in their head and sing it, actually this is true of all musicians. The only "exercise" I know is continued practice. Instead of playing while you sing, try playing a simple 4 note line (maybe the first four notes of the major scale) and see if you can sing or hum it after you play it (not while you play it). At the very least try to match the first note with you instrument then sing w/o playing. With practice you will get better. Take lessons.
I'd like to add the following to ggcg's excellent answer: in addition to the exercise they suggested, try paying attention to what I call your inner ear without, at first, using your guitar. If you can, as you say, "follow a melody" as you play along on your guitar, then you are capable of learning to sing a tune without the aid of your guitar. Try this: Think of a well-known tune, (for example, "Mary Had a Little Lamb" or "Happy Birthday"). Can you hear either tune in your head without actually singing it out loud? Would you be able to tell the difference between those two songs if someone were to quietly hum them in your ear? Then, you can practice using your inner ear. Here are the steps I've used: 1.) Think of an easy well-known, familiar tune, like one of the above. 2.) Try to hear it in your head. 3.) Now, focus only on the first line (or perhaps only on the first two words): "Hap-py Birth-day to You". Hear it in your head a few times. 4.) Next, try to sing those pitches of the first line out loud: Hap-py Birth-day to You. 5.) Now you can use your guitar to check and see if you've matched the pitches of the tune. My explanation might seem a bit tedious, but based on your question I hope that I've broken the steps down into "do-able" chunks. I do this for myself. Cheers!