How to make a command change the sprite?

I know there are many topics about this, but I found them really confusing.

How do I simply make lines of code that 1. adds the sprite 2. actually change the sprite

Tell me like I was an 8 year old, beacuse this is confusing.

Oh, and CSharp. Duh.

I don’t know what “adds the sprite” is. But I can show you how to change the sprite…

GetComponent<SpriteRenderer>().sprite = someOtherSprite;

…where someOtherSprite is a variable or property of type Sprite.

I know I’m late, but thank you so much! This has helped me make my first games!
I figured out on my own how to add the sprite.

public Sprite someOtherSprite;

And then in the editor you drag an image into the box where the script is in the menu.

1 Like