Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

alt text

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): alt text

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

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

alt text alt text

Product Version: UE 4.11
skärmklipp.jpg (16.7 kB)
skärmklipp2.jpg (86.0 kB)
skärmklipp 3.jpg (58.8 kB)
screenshot00001.jpg (594.7 kB)
screenshot00002.jpg (592.2 kB)
more ▼

asked Jun 24 '17 at 08:01 PM in Blueprint Scripting

avatar image

1 5 4 5

avatar image broder_fisk Jun 25 '17 at 02:26 PM

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. alt text 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. alt text 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".

skärmklipp.jpg (51.7 kB)
skärmklipp2.jpg (86.6 kB)
(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

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.

alt text alt text

I mark this question as solved now.

skärmklipp.jpg (35.3 kB)
skärmklipp2.jpg (31.5 kB)
more ▼

answered Jul 24 '17 at 05:29 PM

avatar image

1 5 4 5

(comments are locked)
10|2000 characters needed characters left

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

more ▼

answered Jun 24 '17 at 08:19 PM

avatar image

4k 87 38 150

avatar image broder_fisk Jun 25 '17 at 01:58 PM

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.

avatar image Ninjin Jun 25 '17 at 03:13 PM

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

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Jun 26 '17 at 09:39 PM

avatar image

1 5 4 5

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question