change player sprite by clicking on widget

So basically all I’m trying to do is change the player’s sprite image when I click a widget button. But no matter what I try, it didn’t want to work. I’m doing this in Blueprint of course. I’m still relatively new to UE4 as well, which might be part of the problem…

But yeah, change the sprite image when the player clicks on the widget button. Nothing I’ve tried works. What should I do to achieve this?

I dont use sprites but you could remove and spawn a character

I have tried both like this.
29f92b854c08246deb3aaa689655860f5542ae16.jpeg

And like this.

Edit: For the moment I’m not too concerned about getting flipbooks set up, since this is still early in development and I’m just working with static images at the moment.

Botanicvelious, I had not thought of that one. It sounds like it would work. I’ll give it a go.

Okay, so I tried what Botanicvelious said. Sort of worked. The old character never got destroyed, for some reason, but everything else worked fine.

Just trying what he said. At the very least, it’s gotten me further along than what I was able to come up with on my own.

@Prof_Smash, is your sprite component set to Static mobility by any chance? (Look at the component near the Position/Rotation settings) If so, changing the mobility should allow the SetSprite call to work as expected. You will also be seeing a message in the Output Log about being unable to change the sprite on a Static sprite component.

Cheers,
Michael Noland

No, it is not set to Static mobility. I even double checked that to make sure.

I’m noticing between the PlayerCharacter and the widget blueprints that when I compile one, the other suddenly needs compiling. They are never both “good to go” at the same time. Would that affect things?

Everyone, I got it. The problem was…kind of dumb, actually. So in the above picture, I called the Get Player Character node. Makes sense…but my Player isn’t of the character class, it was of the Pawn class. I was trying all kinds of “Get Player …” nodes when I saw that there was a “Get Player Pawn” node. So I tried that instead, and it fixed the problem. It works exactly as intended.

Thanks for all your help! I’m especially grateful since I never really got the answer straight, but you guys nudged me the right direction. So thank you! :slight_smile: