Jim Carrey says he came out of retirement to star in Sonic The Hedgehog 3 because he "needed the money".