 As Sonic battles his way throughout the Lost Hex , the Deadly Six concoct a plan to capture Sonic and turn him into a robot under their control , but they end up accidentally capturing Tails instead . After Eggman is seemingly killed , Sonic comes across the Deadly Six as they prepare to use the <unk> Tails against him . However , prior to the conversion , Tails managed to reprogram the process to retain his free will and instead helps Sonic to defeat them . Upon reaching the machine and finding it already switched off , Eggman reappears , having faked his death and used the energy harvested to power his latest giant mech . After sending Eggman falling out of the sky , Sonic and Tails return the stolen energy to the world below and return home . The game ends with <unk> and <unk> finding Eggman , who has survived his fall , and digging him out of a soft spot of dirt where he landed on . 
