Changing the material of a skeletal mesh with UI slider

I’m creating an UI for customizing player characters. What I’m currently trying to do, is getting a slider to change the character’s eye color. I have made a float variable that’s affected by the the slider, like this:


…and I know there is a “set material” blueprint node, but what I can’t figure out is how to assign a certain material instance to the character’s eyes depending on the float value. I can’t find out how to connect the two, so to speak.

Update: I changed my approach, to make it a dynamic material and put the eye textures in an array. The float value from the slider is multiplied by 10 and converted to an integer. So far, so good. But I run into the same problem as with the separate material instances - I can change the texture once when dragging the slider, no problem. But as soon as I want there to be multiple textures on the slider, I need to use the variable from my slider in the character blueprint, in which case the character blueprint gets an error:

“This blueprint (self) is not a ChargenUI_C, therefore Target must have a connection.”

I’ve tried to fix that by casting to Chargen_UI; does not work. I’ve also tried it by connecting a “get ChargenUI_ref” to the “get EyeColInt” in which case I get “This blueprint (self) is not a ChargenHUD_C, therefore Target must have a connection.”

I’ve also tried moving stuff around between the two blueprints, but similar things happen.

Update 2: I now have a slider that can be moved in game and I no longer get errors, but the eye color of my character remains unchanged.

The setup:

A character blueprint class called “Human” that is the parent class of ChargenPerson, the character blueprint whose eye color I want to change. Human has a dynamic material and a texture array in their construction script, like this:

My slider, named Slider_Eyes, is bound to a function that outputs the variable EyeColor. I also have an event dispatcher like this:

And finally, this is what it looks like in the ChargenPerson blueprint:

Why won’t the texture change in game when I move the slider?
I have also noticed that while I can cast to the UI, I can’t cast to the slider, and I wonder if that has anything to do with it - or if it’s related to the texture array or the material somehow.