How do I change the player when they touch a collectable?

I’m making a 2d Mario type game and I have collectibles that appear but I’m trying to make it so when you collect certain collectibles you change into a different version of the character. How would I do this? For example, if you collect something you should change from small Mario to big Mario with all separate art and animations. Thanks for any help!

I recently ran into this problem with a game that I’m working on. The easiest solution is to use an Animator Override Controller, which allows you to perform a “sprite swap” without making a single change to an Animator’s logic.

All you have to do is follow these steps:

  1. Design each of the animations for your
    altered character(s)
  2. Create a new Animator Override
    Controller and give it a descriptive name (ex: Big Mario)
  3. Select the Override
    Controller and set its Controller in the Inspector to
    the one your character already
    uses
  4. With the Override
    Controller still selected, change
    each of the animations shown in the
    Inspector to the ones you designed in
    step 1
  5. Repeat as necessary

You can assign Animator Override Controllers via code really easily. Here’s one way, for example:

public AnimatorOverrideController bigMarioAnimator; // Set this in the Inspector

void BecomeBigMario ()
{
   GetComponent<Animator>().runtimeAnimatorController= bigMarioAnimator;
}