Study music theory. Memorize the key signatures, scales and triad forms. Practice them until you can play in any key without having to think about which sharps and flats it has and you know which notes are in any given chord.
Begin learning a new song by playing the roots of each chord. In its simplest form, a bass line is just the roots of the chords. Learn them first for each new piece.
Add leading tones, notes one half-step away from the root, before chord changes. For example, if the first beat of a measure is an A major chord, play a G# on the last beat of the previous measure and then an A on the first beat of the new measure. Always hit the root of the chord on the beat where the chord changes.
Play other notes in the triad on the second beat of a chord. For example, if the A major chord lasts for four beats, play an A on the first beat, a C# on the second beat, an E on the third beat and a leading tone for the next chord on the fourth beat.
Incorporate passing tones to create walking bass lines. If you have four beats of A major then a shift to E major, you can play A-B-C#-D#-E. The B is a passing tone and the D# is a leading tone.
Find opportunities to play the same note through several chord changes. This is called a pedal point. For example, in the progression E minor 7, G7, C7, all the chords include a G; playing a G through the entire progression creates a suspension-resolution effect.
Keep the beat. Use counterpoint beats such as triplets only sparingly.