I've only taken melatonin when my sleep cycle gets severely out of wack.
I used to have really wacky dreams, sometimes bordering on nightmares, but that was years ago. For some reason they haven't cropped up when I've taken it recently.
Then there was the weird habit of waking up at 5:30 AM on the dot, even if I was still sleepy. That seems to have gone away as well.
I think the label says to take melatonin less than an hour before bed, but recently I've had suggestions to take it a few hours before bedtime. Why I'm not sure, but I've noticed I've fallen asleep easier vs back when I took it 1 hour before bed.