Maladaptive Daydreaming: where wild minds come to rest
I began daydreaming when I was 8 and I am currently 16. What you described was the same case with me when I was about 12. I had a group of friends throughout elementery school but at some point I became known to just stand on the side or pace around the friend circle.
I do not experience that anymore. I now have the ability to act completely normal in social situations. It became this way when I started to have a fulfilling social life with friends that I like and like me back.
It may be easier said than done, but I recomend finding people you feel truly happy and comfortable around. I know you have social anxiety, so did I, but you have to go little by little and take social risks to get over Social anxiety and make friends.