Rhythm has been one of the hardest things to learn when it comes to playing bass. It's very easy to get lost in the world of Melodies and Harmonies while giving low consideration to the groove that builds the foundation. When I took my first strides to become better at writing music I fell deep into a tar pit of self-loathing and frustration when my attempts to create melodic bass lines failed miserably. I focused too much effort worrying about chord changes and diatonic notes when there were more important issues that needed to be addressed. I've since come to realize that when I develop rhythms that the melodies start to write themselves. But how do you develop grooves? One technique I use is shifting a note by 1/16th. Here's a very simplified example of what I'm trying to explain:
You start with a simple idea, in this case it's the two notes at the beginning of every bar. When you get more familiar with this shifting concept you will have more in depth ideas but this is left simple just for explaining the concept. I'm taking the last note of the bar shifting it by a 16th note each which completely changes the feel. It's a very simple change but has a big impact on how the bass line feels. Below is a link with drums and bass panned so you can use earbuds to practice with both or just one.
MP3 File of Example
I practice with just this file to get the feel down for each of the different positions and then I will practice trying to shift the note on the fly to make it more difficult(Tip: You can do this by only listening to the drums in the left earbud because I panned the tracks). Take one of your own ideas and practice shifting one note a time and see if you can do it without hearing the bassline first. Our brains register these subtle changes on a very unconcious level so if you're stuck playing a song where the bassline doesn't change very often you can try using this method to make things more interesting for not only yourself but for your audience as well.