How do I change a character's eye color with an UI slider?

I tried this a while ago and couldn’t figure it out; asked and got no replies. Now I’m giving it a try again and I keep getting stuck. I’m trying to change the eye color of a character, not the player character, with a slider.

  • Inside the widget blueprint I have a float that returns the value of the slider, and a truncate node to make an int out of the float. I also have a variable that refers to my character blueprint.

  • The character has two variables related to this: “Eye Col array” which contains the 4 available eye colors (material instances), and “Eye Col” which is the current eye color. Setting the default eye color in the character blueprint works fine:


The widget needs to know whose eye color to change. It seems a way to do this is to find the correct character in the level blueprint (the level contains only one character of this kind, so it should be element 0):

And here is how the slider is supposed to change the eye color:

…Except that it doesn’t. I must have missed something. Any idea what that is?

Your float variable ‘eye color’ will always be a value between 0-1. If you truncate that value, you always get 0. Thus, you always get the 0 element of your material array. Make sure to multiply your float value by your array length-1.

Let me know if it helped! <3

Thanks for replying!
It’s still not working, so there’s probably another issue as well. I did as you said, and for the purpose of testing set my default “eye color” to a higher value than 0 (I used 0,3), and the slider starts at 0,3 when playing the level, so the connection between float and slider works, apparently. But the character’s eye color remains unchanged.

  • Might the UI blueprint not correctly identify the character?
  • Is the UI blueprint unable to change a variable on the character?
  • Maybe the issue is within the character blueprint and has nothing to do with the UI.

The problem seems to be within the character blueprint.

I created an “eye color test” button on my UI, that is supposed to directly set a predetermined eye color. The button doesn’t work.

I also created an “eye color test” input event, that is supposed to set “Eye Col” on the player character when player presses P (in the main level, not the chargen level). Nothing happens.

As you can see, the “eye col” node connected to “set material” (and “event begin play”) returns the default eye color, and the “eye col” connected to the “eye color test” event is “none”.

Your Create Widget function seems to look outdated as it usually doesn’t need a Character input.
Can you try to use the function without the character? I would also try to get your Character Reference by your Player Controller with get GetControlledPawn or jsut use the GetPlayerPawn Node. Also, make sure,
when setting your Character Reference, to cast it to your character that has all the information about the Materials.

Would be awesome to hear if that helps! <3

As I said in my first post, the character is not the player character.

The default player character is a camera actor that can move around but has no mesh. That’s why I can’t just use GetPlayerPawn, but have to find the character in the level blueprint. (The player creates multiple characters which then can be controlled, kind of like the Sims. After a character is created, it’s meant to be saved to a “character bank” and can be placed in the world when the player wishes.)

I created another test to see if the widget really recognized my character; an UI button to make the character jump. It didn’t jump. I tried to put the “get all actors of class” inside the widget blueprint instead of the level blueprint, and now the jump button works! :slight_smile:
I had previously thought finding actors must be done in the level blueprint.

But the eye color still can’t be changed, so I still think I did something wrong in the character blueprint; the UI blueprint seems to be fine now.

I “solved” the problem by not using a slider.

I made a dynamic material instance and change the texture using buttons. I did the same for skin color.



I mark this question as solved now.