It's decided by syllable sounds, not the actual letter.
An Apple, a pie. If you say an pie out loud it sounds wrong but if you say an apple it sounds fine.
Since English isn't your first language, here's a tip for an/a usage:Use "an" when the first letter of the next word is a vowel (e.g. an apple, an egg, an idiot, an orange, an umbrella)Use "a" when the first letter of the next word is a consonant (e.g. a headache, a dog, a plane, a cow)
Then I guess it's okay when I say "I have an Xbox."Unless it's supposed to be a.
Yu - nee - corn
If you were to say "I have a unicorn" wouldn't it be right that it was "I have an unicorn"? But in turn that sounds completely handicapped like "I am an hero" I'm so confused.