Composing a bass line isn't mystical. It's a four-step process you can follow on any song with chord changes.
Step 1: identify the chord progression and tempo
Get the chord chart. Figure out the BPM (use a metronome or a song-tempo finder). Note the key.
Example: a song in A minor at 90 BPM, progression Am - F - C - G (the i-VI-III-VII, very common in rock).
Step 2: roots, locked to kick
First draft: play the root of each chord, one per beat, on whichever string puts it lowest in your range.
beat: 1 2 3 4
Am: A A A A
F: F F F F
C: C C C C
G: G G G G
This already grooves. Play it for a verse; listen.
Step 3: add an eighth-note movement
Pick a sub-rhythm. Common: every other beat is doubled to an eighth note.
beat: 1 & 2 3 & 4
Am: A A A A A A
That's eighths on beats 1 and 3, quarters on 2 and 4. Now the line breathes.
Step 4: add a fill or walk between chords
The last bar of each chord transitions to the next. Use a passing tone:
Am - F transition: ... A - G - F (walks down from A to F)
F - C transition: ... F - E - D - C (walks down from F to C)
C - G transition: ... C - B - A - G (walks down)
G - Am transition: ... G - A (steps up by one whole step)
The "walk" notes (G, E, D, B, A in the examples above) connect the chord changes. They make the bass feel melodic, not just rhythmic.
Practice
Pick a real song. Identify the chord progression. Apply the four steps. Record yourself playing the bass over a backing track or just over the original (turn the original way down so you can hear yourself).
Iterate. Try different sub-rhythms. Try sparser fills, then busier ones. Find what fits.
When in doubt: less
A composed line that breathes is better than one that's busy. Listen to Billie Jean (Louis Johnson). The line is one short riff repeated almost unchanged. That's a memorable bass line.
Next: 5-string basses and beyond.