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.
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?
asked Jun 24 '17 at 08:01 PM in Blueprint Scripting
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.
answered Jul 24 '17 at 05:29 PM
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
answered Jun 24 '17 at 08:19 PM
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! :) 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.
answered Jun 26 '17 at 09:39 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here