In the middle stage of Yogic practice (a stage which is known as the Ghata Avastha), an adept Yogi obtains various Siddhis (perfections). Among which floating in the air and becoming invisible are there.
Quoting from Shiva Samhita:
- When the Yogi, though remaining in Padmasana, can rise in the air and leave the ground, then know that he has gained Vayu-siddhi
(success over air), which destroys the darkness of the world.
54 The Yogi acquires the following powers :—vakya siddhi (prophecy), transporting himself everywhere at will (Kamachari),
clairvoyance (duradristhi), clairaudience (durashruti), subtle-sight
(shukshma-drishti), and the power of entering another’s body
(parakaypravesana), turning base metals to gold by rubbing them with
his excrements and urine, and the power of becoming invisible, and
lastly, moving in the air.
Verses 42 and 54 from Chapter 3.
These Siddhis are obtained by practicing Yoga mostly Pranayama.