Montenegrian is already proclaimed to be the official language of Montenegro. But let's leave politics and politicians aside. Official languages of ex-Yugoslavia were:
Serbo-Croat (or Croato-Serbian), which was spoken in Croatia, Bosnia&Hercegovina, Montenegro and Serbia, with small dialectal differences.
It was actually a bit more complicated than that.
When it comes to the
standard language, there existed at least two distinct standards -- the Croatian and the Serbian one -- which were similar enough to be mutually intelligible easily, but still had substantial differences in some parts of vocabulary, and also had some relatively minor grammatical and orthographical differences.
If you wanted to write in Serbo-Croat, you had to decide which one of these standards to follow and stick to it consistently. In Bosnia, the standard language was the ijekavian version of the Serbian standard, with some minor differences in vocabulary (so this arguably constituted the third standard). Note that these differences were
not dialectal, since these were artificial standard languages. Nowadays, these three standards are considered as separate official languages of these countries, and the fourth (Montenegrin) one is in the making.
As for the vernacular dialects, there exists a dialect continuum throughout the South Slavic area (or rather existed before the standard languages became dominant in the modern age). Nowadays, fewer and fewer people are speaking the original folkish dialects of their area; most of them speak some mix between their regional dialect and the standard. However, when spoken in their original form, more or less all of the neighboring dialects are mutually intelligible, but the differences grow rapidly with distance. In many places, the speakers of dialects living only 50-100km apart have major difficulties in communication if they don't know the standard language -- and at longer distances, totally different languages merge more or less seamlessly into each other (Slovenian and Bulgarian are as different as, say, Portuguese and French, but each one is very similar to the neighboring dialects across the border in Croatia and Serbia).
A small curiosity: People from northern Serbia often can't understand people from southern Serbia. People from northern Croatia often can't understand people from southern Croatia. But people from northern Serbia and northern Croatia understand each other without a problem.
Southern Serbian Torlak dialects form a close continuum with Macedonian and Bulgarian, whose grammar is extremely different from the other South Slavic languages. Basically, the further southeast you go in Serbia, the fewer cases there are in the local dialect, until they all disappear and the definte article appears -- and then you suddenly realize that people are speaking Bulgarian or Macedonian.

As for Northern Croatia and Northern Serbia, what you write holds only for the speakers of Shtokavian dialects. Kajkavian dialects from Northwestern Croatia, especially those from Medjimurje, are barely intelligible for any South Slavic speaker who hasn't been exposed to them.