Sonic the Hedgehog 3 brought us two scenes after the main movie. One of those end credit scenes perfectly set up Sonic 4.
When he finds out the Eclipse Cannon's true purpose, he works with Sonic in the end to help stop it, sacrificing himself by saying, "if I can't rule the world ... I might as well save it!" ...