Past Perfect is used when we want to say that an event happened before another event.
Example: Tom left the party at 8PM. Jane arrived at the party at 9 PM. --> When Jane arrived at the party, Tom had already gone.
When explaining Past Perfect to my students, I tell them it's like the Present Perfect, told later. -->
Present Perfect: Who is that man? I have never seen him before.
At the moment of speaking, you see that man, so the "I haven't seen him" period is over. Thus, when you talk about this a few days/months/years later, you can say that until that moment, you hadn't seen him.
Past Perfect: I didn't know who that man was. I hadn't seen him before.
If you are waiting for the bus, but it doesn't come, you can say:
I have been waiting for the bus for an hour.
If you tell your friend about this a few days later, you can say:
When the bus came, I had been waiting for an hour.
Hope this helps.