Music theory or performance will really help you a lot if you're struggling with this. As a rule, I have at least four to six melodies going at any one time in a beat (most at very low levels) in order to make the sound of the beat complete and ring true to the listener as something that's complex and variform. This is what I mean when I say music theory or performance is important. Without developing your own style of playing and your own style of composition, you're going to struggle with composing melodies that go into the beat (unless, that is, you are a superb improviser).
It's important to take cues from the greats that have come before us, and depending on what your style is, you can go different places. If you like jazzy, groovier stuff, listen to jazz and listen to people that have been informed by jazz, like Quincy Jones' production. If you like what you hear that isn't jazz, listen to some more complex EDM and pop as well because a lot of the melodies you'll want to use can actually be inspired by what's going on there (as these forms have their basis in classical musical theory). Of course, listen to hip-hop as well, because that's the only way you'll know what's going on in your personal field.
Anyways, I hope this helped.