We experimentally study the cavity formation when heated spheres impact onto water at low and high subcooling. The observations present that the formation and appearance of the cavity are affected by the boiling modes and the heat transfer intensity. In the nucleate-boiling regime, a rough cavity can be formed at a rather low impact velocity, while at the same velocity, the cavity formed in the film-boiling regime may have a very smooth interface with a stable vapor layer around the sphere. We discuss the effects of the impact speed, water and sphere temperatures on the stability of the vapor layer. For low subcooled water, the stable vapor layer will be disturbed when increasing the impact velocity, leading to a disturbed cavity. For high subcooled water, the film boiling has a particular boiling model in which the vapor layer around the sphere cannot keep its stability. In this particular film-boiling regime, no cavities can be formed at low impact velocities and only broken cavities can be formed at high impact velocities.