My fish keeps floating on his side, but only when I am not directly in front of his tank. when I am in front of his tank he acts normal (He floats normally and looks more happy). He lives in a 5 gallon aquarium by himself with a fake plant and a statue of a peacock. I have put betta fish, aquarium salt, and stress clear before when this was less of a problem because I have had a betta do this exact same thing and I don't know what I should do. I have had 4 bettas before, the very first died from poison (Statue had too much paint on it, was a statue made by top fin.) my second died from stress (Complete accident), My third died from a disease relating to old age (I think cancer) and my fourth (Which I bought at the same time as the third) died from this disease.
Good observation first, if your betta has good shape and activity and you water parameters are ok I would start by doing some fasting as it could be very probable that is only food excess. Actually this is a good practice to skip a meal at least once of twice a month.
If that doesn't help we should identify what infection/treatment it could be but sadly there is not much to do in such cases.
Hopefully it's going to be food excess.